ContentLayer.dev
ContentLayer.dev
"Contentlayer": https://github.com/contentlayerdev/contentlayer (384 ⭐). "Turns your content into data - making it super easy to import MD(X) and CMS content in your app"
- seems pretty good at first glance … but
- very alpha with most of docs unfinished
- one of founders of prisma seems to be behind it
- somehow it doesn't feel quite right e.g. no query language, instead i get functions like
allPosts
- That said … is that a big deal in a KISS solution
- Here's the example of what leerob.io is doing https://github.com/leerob/leerob.io/blob/main/contentlayer.config.ts - quite simple and support for computed fields which is nice
- Still have a bit of a "bad smell" instinct e.g. creating a mini database is separate from adding computed fields (?)
Key points
- Restricted (i think) to one
contentDirPath
under which you have to all your different types of documents - You can then restrict document types based on glob patterns afaict
- They are using kentcdodds mdx-loader under the hood - see https://github.com/contentlayerdev/contentlayer/blob/main/packages/@contentlayer/core/src/mdx.ts
- How you then use the content: see example here https://github.com/leerob/leerob.io/blob/main/pages/blog/%5Bslug%5D.tsx
FAQs
- Can you pass in components to be available in markdown in one common location used like in next-mdx-remote?