kentcdodds / mdx-bundler

🦤 Give me MDX/TSX strings and I'll give you back a component you can render. Supports imports!
MIT License
1.78k stars 75 forks source link

Question: Using remark/rehype plugins on a per-page basis? #197

Closed colinsteidtmann closed 1 year ago

colinsteidtmann commented 1 year ago

Hi, I want to use a rehype plugin, rehype-external-links, for a few specific mdx files. Is it possible to do this without creating separate bundleMDX({...}) functions?

Owen-Tsai commented 1 year ago

Is it possible in your use case to create different options and pass them to the bundleMDX method? In the ideal situation you'll just need to slightly modify your existing code.

colinsteidtmann commented 1 year ago

Yes, it's totally possible. I wrote this post before I understood mdx-bundler. Since you're bundling mdx files on a per-file basis, then you can easily have a general function that bundles an mdx file with generic plugins, but allow it to accept an array of additional plugins that you may want for specific files.