fix: dedupe heading slugs to prevent duplicate ids on doc pages#1961
Open
sanketssc wants to merge 1 commit intosveltejs:mainfrom
Open
fix: dedupe heading slugs to prevent duplicate ids on doc pages#1961sanketssc wants to merge 1 commit intosveltejs:mainfrom
sanketssc wants to merge 1 commit intosveltejs:mainfrom
Conversation
|
@sanketssc is attempting to deploy a commit to the Svelte Team on Vercel. A member of the Team first needs to authorize it. |
There was a problem hiding this comment.
Pull request overview
This PR addresses duplicate heading id values on docs pages by de-duplicating generated heading slugs per page, keeping rendered heading anchors and the “On this page” TOC metadata aligned.
Changes:
- Add per-page slug de-duping when generating
sections/subsectionsmetadata for the docs TOC. - Add per-page slug de-duping when rendering heading
idattributes and permalinkhrefs in markdown output.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
| packages/site-kit/src/lib/server/content/index.ts | De-dupes sections and subsections slugs so TOC entries remain unique per page. |
| packages/site-kit/src/lib/markdown/renderer.ts | De-dupes rendered heading ids / permalinks to avoid duplicate IDs in generated HTML. |
51fc9e6 to
8230b60
Compare
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.
Fixes #1281
When a module exposes a class and a type with the same name (e.g. the
Springclass and the legacyinterface Spring<T>insvelte/motion), the generator emits two## SpringH2s. The renderer assigned both the sameid="Spring", which:/docs/svelte/svelte-motion#Springonly ever reached the first heading, the legacy interface section was unreachable),Springlink highlighted both at once).This PR dedupes heading slugs per page. The first occurrence keeps the bare slug, subsequent occurrences get
-1,-2, … suffixes. The same dedupe is applied in two places so they stay in sync:packages/site-kit/src/lib/markdown/renderer.ts— headingid+ permalinkhrefin rendered HTML.packages/site-kit/src/lib/server/content/index.ts—sections/subsectionsmetadata that powersOnThisPage.svelte.Result on
/docs/svelte/svelte-motion: firstSpring(class) stays at#Spring, legacy interface section becomes#Spring-1. Each TOC entry now activates independently.Before submitting the PR, please make sure you do the following
feat:,fix:,chore:, ordocs:.