feat(mdx): support recma plugins (#10241)

This commit is contained in:
Sébastien Lorber 2024-06-21 19:25:32 +02:00 committed by GitHub
parent 4ad425a88f
commit cc506c8950
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
18 changed files with 45 additions and 0 deletions

View file

@ -54,6 +54,7 @@ export type MDXOptions = {
admonitions: boolean | Partial<AdmonitionOptions>;
remarkPlugins: MDXPlugin[];
rehypePlugins: MDXPlugin[];
recmaPlugins: MDXPlugin[];
beforeDefaultRemarkPlugins: MDXPlugin[];
beforeDefaultRehypePlugins: MDXPlugin[];
};
@ -150,6 +151,10 @@ async function createProcessorFactory() {
...(options.rehypePlugins ?? []),
];
// Maybe we'll want to introduce default recma plugins later?
// For example https://github.com/domdomegg/recma-mdx-displayname ?
const recmaPlugins = [...(options.recmaPlugins ?? [])];
if (format === 'md') {
// This is what permits to embed HTML elements with format 'md'
// See https://github.com/facebook/docusaurus/pull/8960
@ -173,6 +178,7 @@ async function createProcessorFactory() {
...options,
remarkPlugins,
rehypePlugins,
recmaPlugins,
providerImportSource: '@mdx-js/react',
};