-
(I'm starting a separate thread on this topic since the other thread is marked answered.) In thread 1891 is was recommended to import and use the rehype plugin for code highlighting in import images from 'remark-images'
import emoji from 'remark-emoji'
import rehypeHighlight from 'rehype-highlight'
const config = {
// customized webpack config
webpack: (config, options) => {
// as per https://github.com/mdx-js/mdx/discussions/1891#discussioncomment-1936148
config.module.rules.push({
test: /\.mdx?$/,
use: [
// The default `babel-loader` used by Next:
options.defaultLoaders.babel,
{
loader: "@mdx-js/loader",
/** @type {import('@mdx-js/loader').Options} */
options: {
/* jsxImportSource: …, otherOptions… */
rehypePlugins: [rehypeHighlight],
remarkPlugins: [images, emoji],
providerImportSource: "@mdx-js/react",
},
},
],
});
return config;
},
pageExtensions: ['js', 'jsx', 'md', 'mdx', 'tsx', 'ts'],
}
export default config However,
presumably because the rehype highlight plugin is not configured with the PS: @wooorm points out the documentation in “Using plugins” section of the “Extending MDX” article which recommends configuration of plugins like so:
However, this seems specific to stand-alone use.... unless the syntax rehypePlugins: [[rehypeKatex, {throwOnError: true, strict: true}]] works inside a webpack option as well. Does it? |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 1 reply
-
That syntax works everywhere. You need to change options though, because you are using different plugins. |
Beta Was this translation helpful? Give feedback.
That syntax works everywhere. You need to change options though, because you are using different plugins.