-
-
Notifications
You must be signed in to change notification settings - Fork 2.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Mdx/plugin unshift #4248
Mdx/plugin unshift #4248
Conversation
🦋 Changeset detectedLatest commit: fa02b69 The changes in this PR will be included in the next version bump. This PR includes changesets to release 5 packages
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM! Thanks for the quick work on this 👍
@@ -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 }]); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I was wondering if there is a slightly better way of doing this, Im never a fan of unshift()
[ [rehypeRaw, { passThrough: nodeTypes}] , ...rehypePlugins ]
I feel this returning a new array would be easier, and a more performant solution
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I agree, It's probably a better alternative. Array#unshift
was just the first thing that came to mind when I thought about this issue.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
just a thought about unshifting to a new array
Changes
pnpm exec changeset
Put built in rehype plugins before user added.
Testing
No thorough testing was done due to the complexity of testing every major rehype plugin. Changing the load order should have minimal to no effect on usage.
Docs
No visible change. No documentation mentioned builtin plugins being loaded last.
Why
Specifically the
rehypeCollectHeadings
impacted one of my rehype plugins.rehypeAutolinkHeadings
requires ids to be added to headings for it to work, with pre this pr configuration, these ids were added after my plugin being ran.Context in discord thread
@bholmesdev