#How to read mdx files from local files? What is leerob.io's 'contentlayer/generated' code?

19 messages · Page 1 of 1 (latest)

hearty musk
native violetBOT
#

🔎 This post has been indexed in our web forum and will be seen by search engines so other users can find it outside Discord

🕵️ Your user profile is private by default and won't be visible to users outside Discord, if you want to be visible in the web forum you can add the "Public Profile" role in id:customize

✅ You can mark a message as the answer for your post with Right click -> Apps -> Mark Solution
(if you don't see the option, try refreshing Discord with Ctrl + R)

haughty summit
#

in tsconfig.json we can see that it is a paths alias to something generated at build (?) time

    "paths": {
      "contentlayer/generated": ["./.contentlayer/generated"]
    },
#

It seems to maybe be indexing the MDX files to aid in navigation?

#

This is definitely a pretty complicated way if you want do just load some static MDX files, but a pretty good example of how to do a blog with metadata from the MDX posts like

---
title: 'Programming Portfolios'
publishedAt: '2017-02-24'
summary: 'Tips for creating a portfolio that stands out.'
---
broken stone
broken stone
#

but it might require some more understanding to initially work it out (for markdown, id say better, but just pages with jsx, harder)

haughty summit
#

in either case, try the built in Next MDX support first, it is pretty good

broken stone
#

@hearty musk are you there/ do you understand what minabot and I shared...

hearty musk
#

Absolutely sorry for not replying! Was Trying these as you shared thank you so much

broken stone
#

ahh yeah thats understandable

#

(i just wanted to make sure you didn't leave the server or give up like some do)

native violetBOT
#
✅ Success!

This question has been marked as answered! If you have any other questions, feel free to create another post

Jump to answer

[Click here](#1152631478342131812 message)

candid vigil
#

contentlayer is very good when you need typed metadata for mdx files