Prevent heading anchor links on non-Starlight content#3181
Merged
HiDeoo merged 3 commits intowithastro:mainfrom May 8, 2025
Merged
Prevent heading anchor links on non-Starlight content#3181HiDeoo merged 3 commits intowithastro:mainfrom
HiDeoo merged 3 commits intowithastro:mainfrom
Conversation
🦋 Changeset detectedLatest commit: 9d798dd The changes in this PR will be included in the next version bump. This PR includes changesets to release 1 package
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 |
✅ Deploy Preview for astro-starlight ready!
To edit notification comments on pull requests, go to your Netlify site configuration. |
Eveeifyeve
approved these changes
May 6, 2025
florian-lefebvre
approved these changes
May 7, 2025
ematipico
approved these changes
May 7, 2025
MoustaphaDev
approved these changes
May 7, 2025
Merged
HiDeoo
added a commit
to hippotastic/starlight
that referenced
this pull request
May 14, 2025
* main: (151 commits) i18n(fr): update slot translation and update Astro Docs links (withastro#3196) i18n(ko-KR): update `plugins.mdx` (withastro#3197) i18n(fr): update `resources/plugins` (withastro#3195) chore(deps): update changesets/action action to v1.5.2 (withastro#3191) docs(plugins) Add a link to starlight-scroll-to-top plugin (withastro#3194) [ci] format docs(showcase): add fluid-dnd showcase (withastro#3193) [ci] format Cookie API website for Showcase (withastro#3188) chore(deps): update changesets/action action to v1.5.1 (withastro#3187) [ci] format add showcase sonar (withastro#3183) [ci] release (withastro#3166) Prevent heading anchor links on non-Starlight content (withastro#3181) i18n(de): update `css-and-tailwind.mdx` (withastro#3174) chore(deps): update changesets/action action to v1.5.0 (withastro#3179) i18n(ko-KR): update Korean UI strings (withastro#3168) i18n(fr): update `guides/css-and-tailwind.mdx` (withastro#3173) i18n(ko-KR): update `css-and-tailwind.mdx` (withastro#3172) docs: update Tailwind manual installation instructions (withastro#3170) ...
1 task
Yoxnear
pushed a commit
to Yoxnear/starlight-custom
that referenced
this pull request
Jul 23, 2025
Co-authored-by: Eveeifyeve <88671402+Eveeifyeve@users.noreply.github.com> Co-authored-by: florian-lefebvre <69633530+florian-lefebvre@users.noreply.github.com> Co-authored-by: ematipico <602478+ematipico@users.noreply.github.com> Co-authored-by: MoustaphaDev <81974850+MoustaphaDev@users.noreply.github.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.

Description
In Starlight
0.34.0, support for generating clickable anchor links for headings was added. For Markdown and MDX content, a rehype plugin is used to generate the links.When the feature is not disabled, this plugin runs unconditionally, which means that these links are generated for non-Starlight content like individual Markdown page or content not from the Starlight
docscontent collection.This PR prevents this behavior by checking if the virtual file path is part of the Starlight
docscontent collection first, and bails if it is not.For testing, I relied on E2E tests as it seems that on Windows, file path separators are inconsistent when the rehype plugin is used on Markdown vs MDX files. I'll investigate and open a separate issue/PR for that on the Astro repo.
Here is a preview of the changes before and after the fix for an individual Markdown page: