fix: dedupe heading slugs to prevent duplicate ids on doc pages#1961
fix: dedupe heading slugs to prevent duplicate ids on doc pages#1961sanketssc wants to merge 1 commit into
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. |
8230b60 to
57d5ef6
Compare
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
57d5ef6 to
56f86a4
Compare
|
fair point this does make it order dependent and if future changes happen it will point to wrong thing. few things could be worked on maintaining internal ids for slugs but thats currently not being done If we want automatic slug generations which is present currently i think current one work in most of the cases additionally i am open to suggestions if there are any regarding this |
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:.