Add plugin

The way that you can add custom plugins to the mix, is by adding them before or after a built-in plugin.

Let's say we want to use the "remark-github-alerts" plugin. It must be added before or after a built-in remark plugin. Do the same with rehype plugins too. Let's say we want to add it after the built-in "remark-gfm" plugin.

import remarkExamplePlugin from "remark-example-plugin"
 
mdxPreprocess({
    onTransform: async (markup, options) => {
        return await unifiedTransformer(markup, options, {
            builtInPlugins: {
                remarkGfm: {
                    plugins: {
                        before: remarkExamplePlugin,
                        after: [
                            () => (tree) => {
                                console.dir(tree)
                            },
                        ],
                    },
                },
            },
        })
    },
})

Something like "remark-github-alerts" is already built-in.

NOTE

It doesn't matter if the built-in plugin is disabled, the custom plugin added by you will work.

Return to top