summaryrefslogtreecommitdiff
path: root/packages/integrations/mdx/src
diff options
context:
space:
mode:
authorGravatar Ben Holmes <hey@bholmes.dev> 2022-08-05 22:51:38 -0500
committerGravatar GitHub <noreply@github.com> 2022-08-05 20:51:38 -0700
commit77cede720b09bce34f29c3d2d8b505311ce876b1 (patch)
treeeffca866843064b798d68dd5ebde993f837d8725 /packages/integrations/mdx/src
parent97cf0cd893b950a48ffa631247528b4b4ad73109 (diff)
downloadastro-77cede720b09bce34f29c3d2d8b505311ce876b1.tar.gz
astro-77cede720b09bce34f29c3d2d8b505311ce876b1.tar.zst
astro-77cede720b09bce34f29c3d2d8b505311ce876b1.zip
[MDX] Prevent overriding `collect-headings` plugin (#4181)
* fix: make rehypeCollectHeadings a required plugin * docs: update README on rehypePlugins * test: remove collect-headings override test * docs: remove extends from rehype docs * chore: changeset
Diffstat (limited to 'packages/integrations/mdx/src')
-rw-r--r--packages/integrations/mdx/src/index.ts9
1 files changed, 7 insertions, 2 deletions
diff --git a/packages/integrations/mdx/src/index.ts b/packages/integrations/mdx/src/index.ts
index 85eec630e..2c7247237 100644
--- a/packages/integrations/mdx/src/index.ts
+++ b/packages/integrations/mdx/src/index.ts
@@ -27,8 +27,11 @@ type MdxOptions = {
frontmatterOptions?: RemarkMdxFrontmatterOptions;
};
-const DEFAULT_REMARK_PLUGINS = [remarkGfm, remarkSmartypants];
-const DEFAULT_REHYPE_PLUGINS = [rehypeCollectHeadings];
+const DEFAULT_REMARK_PLUGINS: MdxRollupPluginOptions['remarkPlugins'] = [
+ remarkGfm,
+ remarkSmartypants,
+];
+const DEFAULT_REHYPE_PLUGINS: MdxRollupPluginOptions['rehypePlugins'] = [];
function handleExtends<T>(config: WithExtends<T[] | undefined>, defaults: T[] = []): T[] {
if (Array.isArray(config)) return config;
@@ -68,6 +71,8 @@ function getRehypePlugins(
if (config.markdown.syntaxHighlight === 'shiki' || config.markdown.syntaxHighlight === 'prism') {
rehypePlugins.push([rehypeRaw, { passThrough: nodeTypes }]);
}
+ // getHeadings() is guaranteed by TS, so we can't allow user to override
+ rehypePlugins.push(rehypeCollectHeadings);
return rehypePlugins;
}