Allow extra loaders to be passed as a plugin option in next-mdx #16930
shuklaayush
started this conversation in
Ideas
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
Since
next-mdx
doesn't support YAML frontmatter, why not expose the webpack config to allow extra loaders to be passed as a plugin argument? Like this:We can then use a custom loader function to extract frontmatter, add a default layout, or do other pre-processing. In my opinion, it's a more flexible solution than relying on 3rd party plugins.
Example loader:
Here, Layout is an HOC which takes the extracted frontmatter as an argument to define the default MDX layout. Since the frontmatter is not exported as a variable from within the MDX, Fast Refresh still works.
Beta Was this translation helpful? Give feedback.
All reactions