From 869d0093596b709cfcc1a1a95ee631b48d6d1c26 Mon Sep 17 00:00:00 2001 From: Jakob Helgesson Date: Wed, 10 Aug 2022 23:10:06 +0200 Subject: [PATCH] Mdx/plugin unshift (#4248) * Add builtin rehype plugin to beginning * Add Changeset * Do the same to rehypeRaw for consistency --- .changeset/fuzzy-emus-develop.md | 5 +++++ packages/integrations/mdx/src/index.ts | 4 ++-- 2 files changed, 7 insertions(+), 2 deletions(-) create mode 100644 .changeset/fuzzy-emus-develop.md diff --git a/.changeset/fuzzy-emus-develop.md b/.changeset/fuzzy-emus-develop.md new file mode 100644 index 000000000..b7b7321d6 --- /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 d88e67016..05b803705 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; }