Skip to content

Commit

Permalink
Mdx/plugin unshift (#4248)
Browse files Browse the repository at this point in the history
* Add builtin rehype plugin to beginning

* Add Changeset

* Do the same to rehypeRaw for consistency
  • Loading branch information
svemat01 authored Aug 10, 2022
1 parent d087286 commit 869d009
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
5 changes: 5 additions & 0 deletions .changeset/fuzzy-emus-develop.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@astrojs/mdx': patch
---

Load builtin rehype plugins before user plugins instead of after
4 changes: 2 additions & 2 deletions packages/integrations/mdx/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down

0 comments on commit 869d009

Please sign in to comment.