c8r / x0

Document & develop React components without breaking a sweat
https://compositor.io/x0/
MIT License
1.71k stars 65 forks source link

Expose @mdx-js/loader configuration #101

Open silvenon opened 6 years ago

silvenon commented 6 years ago

I'm not sure if there's currently a way to extend or override MDX configuration. One way could be to use smart merging. Another way could be to add a mdx field in x0 configuration in package.json:

"x0": {
  "mdx": "./mdx.config.js"
}
// mdx.config.js
const math = require('remark-math')
const katex = require('rehype-katex')

module.exports = ({ defaultMdPlugins, defaultHastPlugins }) => ({
  mdPlugins: [
    ...defaultMdPlugins,
    math,
  ],
  hastPlugins: [
    ...defaultHastPlugins,
    katext,
  ],
})

I prefer the latter strategy. Even though it results in an additional configuration file, it's probably more straightforward to implement and use.