0.2.5
ℹ️ [TLDR] 0.2.5 brings significant flexibility to processing MDX and markdown documents, along with a number of smaller fixes and improvements.
✨ Markdown Processing
Contentlayer now supports custom processing for markdown content. This proposal was raised by @causztic in #202.
Previously, we were presenting developers with a base set of remark and rehype plugins for processing markdown. This prevented cases like being able to pass options to some of these plugins.
Rather than building out (opinionated) infrastructure to accommodate options for these base plugins, we chose to provide full flexibility in overriding these plugins and bringing your unified building pattern. This can be done via a markdown option passed to makeSource.
import rehypeStringify from 'rehype-stringify'
import remarkFrontmatter from 'remark-frontmatter'
import remarkParse from 'remark-parse'
import remark2rehype from 'remark-rehype'
makeSource({
// your other options ...
markdown: (builder) => {
builder
.use(remarkFrontmatter)
.use(remarkParse)
.use(remark2rehype)
.use(rehypeStringify)
}
})- Take care to ensure that what you return from this function is an HTML string. We recommend you use
rehypeStringifyfor this. Otherwise you may break Contentlayer's intended behavior. - If using this
markdownoption, theremarkPluginsandrehypePluginsoptions will not be used. You should choose one approach tr the other. - The code snippet above shows the default plugins used by Contentlayer. If you want to ensure compatibility, we recommend starting with these options.
✨ MDX Processing
To address #8 (from @mshick) and #192 (from @Saeris), we've added additional flexibility when processing mdx content. You can now pass mdxOptions as a makeSource option to modify the built-in MDX configuration, which is passed to the @mdx-js/mdx compile method.
makeSource({
// your other options ...
mdxOptions: { /* ... */ }
})- If you use
mdxOptions, bothremarkPluginsandrehypePluginsoptions will be ignored. Choose one approach or the other.
Developer Experience Improvements
The following changes have been introduced to improve the developer experience:
✨ Contentlayer now makes sure you're using the same version of contentlayer and next-contentlayer and will provide a helpful error message if not. (#187 from studioprisoner)
Other Improvements & Fixes
🐞 _index.json still gets created when there are no content source files. (#208 from @jpedroschmitz)
🔧 Updated dependencies to support earlier versions of esbuild. (#204, #205 from @nayaabkhan)
🔧 Also updated various dependencies.
🔧 Avoid fatal error message (it wasn't a fatal error) during installation on Vercel. (#178)
🚀 Successful Beta Launch!
We officially released Contentlayer into Beta last month (April 2022)! 🎉 Since the launch we've seen a continued increase in community activity, including new issues, pull requests, and ideas.
A big thanks is due both to everyone who has helped Contentlayer get to this major milestone, but also to our newest members who are taking an active role in the continued evolution of what we believe will be the best way for developers to work with content for the web.
0.2.5 Contributors
The following community members who contributed to this release:
Big thanks for these contributions, and a thanks is due to all those who have contributed ideas, feedback, and support that has led to these changes.
Now, onto the next iteration! ⚡

