-
-
Notifications
You must be signed in to change notification settings - Fork 9.4k
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
Bug: Add remark-slug
and remark-external-links
to Vite builder
#21796
Bug: Add remark-slug
and remark-external-links
to Vite builder
#21796
Conversation
New dependency changes detected. Learn more about Socket for GitHub ↗︎ 👍 No new dependency issues detected in pull request Bot CommandsTo ignore an alert, reply with a comment starting with Pull request alert summary
📊 Modified Dependency Overview:
|
…n-no-html-anchors
…nchors' of github.com:storybookjs/storybook into 20519-bug-markdown-headings-in-mdx-are-broken-no-html-anchors
const modulesToTransform = [ | ||
'@angular', | ||
'ccount', | ||
'rxjs', | ||
'nanoid', | ||
'uuid', | ||
'lit-html', | ||
'lit', | ||
'@lit', | ||
'@mdx-js', | ||
'ccount', | ||
'character-entities', | ||
'decode-named-character-reference', | ||
'estree', | ||
'is-absolute-url', | ||
'lit', | ||
'lit-html', | ||
'mdast', | ||
'micromark', | ||
'nanoid', | ||
'remark', | ||
'rxjs', | ||
'slash', | ||
'space-separated-tokens', | ||
'stringify-entities', | ||
'unified', | ||
'unist', | ||
'uuid', | ||
'vfile', | ||
'vfile-message', | ||
'mdast', | ||
'micromark', | ||
'unist', | ||
'estree', | ||
'decode-named-character-reference', | ||
'character-entities', | ||
'zwitch', | ||
'stringify-entities', | ||
'slash', | ||
]; |
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.
- Sort alphabetically
- Add
space-separated-tokens
andis-absolute-url
, ESM only modules used byremark-external-links
Closes #20519
What I did
This PR adds
remark-slug
andremark-external-links
plugins to the MDX plugin in the Vite builder. The plugins are already added toaddon-docs
, however that only has an effect in Webpack projects. The changes to the mdx plugin here are direct copy-paste from https://github.com/storybookjs/storybook/blob/next/code/addons/docs/src/preset.ts#L55-L66Not having these plugins caused the issue where headings wouldn't automatically get
id
s assigned, and thus no anchors. This fixes that.In the near future we probably want to move all MDX handling from the Vite builder to the docs addon, to not force Vite users to have all those dependencies.
How to test
This is not an issue in autodocs, only standalone MDX files.
Create a standalone MDX file with the following content:
Hover over the headings and see the anchor icon appear. Click the H2 heading, copy the URL and open it in a new tab. See that it scrolls down to the H2 when opened.
Checklist
MIGRATION.MD
Maintainers
make sure to add the
ci:merged
orci:daily
GH label to it.["cleanup", "BREAKING CHANGE", "feature request", "bug", "documentation", "maintenance", "dependencies", "other"]