Mdx/plugin unshift (#4248)

* Add builtin rehype plugin to beginning

* Add Changeset

* Do the same to rehypeRaw for consistency
This commit is contained in:
Jakob Helgesson 2022-08-10 23:10:06 +02:00 committed by GitHub
parent d087286daa
commit 869d009359
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 7 additions and 2 deletions

View file

@ -0,0 +1,5 @@
---
'@astrojs/mdx': patch
---
Load builtin rehype plugins before user plugins instead of after

View file

@ -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;
}