Join egghead, unlock knowledge.

Want more egghead?

This lesson is for members. Join us? Get access to all 3,000+ tutorials + a community with expert developers around the world.

Unlock This Lesson
1×
Become a member
to unlock all features

Level Up!

Access all courses & lessons on egghead today and lock-in your price for life.

Autoplay

    Use Markdown Files in the Next.js Pages Directory Instead of React Components

    John LindquistJohn Lindquist
    reactReact
    nextNext.js

    With a couple of tweaks to the next.config.js, you can begin using Markdown files which will be represented by URLs in the pages directory. With this approach, you could author an entire site using only Markdown files and sprinkling in React components inside your Markdown files where necessary.

    Code

    Code

    Become a Member to view code

    You must be a Member to view code

    Access all courses and lessons, track your progress, gain confidence and expertise.

    Become a Member
    and unlock code for this lesson
    Discuss

    Discuss

    Transcript

    Transcript

    Instructor: 0:00 With a content markdown file inside of our pages directory, you might assume you could navigate to content and see that page, but we get a 404. You can enable this by going into your config, and inside of with MDX, pass in an object for your configuration with a page extensions property.

    0:20 This is an array. We need to pass in JavaScript so that our default JS file is supported, so JS. We'll just add MDX as well. I'll hit save.

    0:35 Next, we'll pickup that change automatically and even refresh page this page for you, and you can see it's now rendering this content page at the /content URL. If I create another page, we'll call it new file about .MDX with header one, just inaudible about, hit save and navigate to about.