diff --git a/.changeset/fuzzy-emus-develop.md b/.changeset/fuzzy-emus-develop.md new file mode 100644 index 000000000000..b7b7321d649d --- /dev/null +++ b/.changeset/fuzzy-emus-develop.md @@ -0,0 +1,5 @@ +--- +'@astrojs/mdx': patch +--- + +Load builtin rehype plugins before user plugins instead of after diff --git a/packages/integrations/mdx/src/index.ts b/packages/integrations/mdx/src/index.ts index d88e67016bcb..05b80370568e 100644 --- a/packages/integrations/mdx/src/index.ts +++ b/packages/integrations/mdx/src/index.ts @@ -62,10 +62,10 @@ function getRehypePlugins( let rehypePlugins = handleExtends(mdxOptions.rehypePlugins, DEFAULT_REHYPE_PLUGINS); if (config.markdown.syntaxHighlight === 'shiki' || config.markdown.syntaxHighlight === 'prism') { - rehypePlugins.push([rehypeRaw, { passThrough: nodeTypes }]); + rehypePlugins.unshift([rehypeRaw, { passThrough: nodeTypes }]); } // getHeadings() is guaranteed by TS, so we can't allow user to override - rehypePlugins.push(rehypeCollectHeadings); + rehypePlugins.unshift(rehypeCollectHeadings); return rehypePlugins; }