Skip to content

Commit 06b85b8

Browse files
authored
Prepend ToC ids with toc prefix to ensure unique (#1915)
1 parent cbce034 commit 06b85b8

File tree

2 files changed

+2
-2
lines changed
  • packages/skeleton/src/lib/utilities/TableOfContents
  • sites/skeleton.dev/src/routes/(inner)/utilities/table-of-contents

2 files changed

+2
-2
lines changed

packages/skeleton/src/lib/utilities/TableOfContents/crawler.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ export function tocCrawler(node: HTMLElement, args?: TOCCrawlerArgs) {
4444
.replaceAll(/[^a-zA-Z0-9 ]/g, '')
4545
.replaceAll(' ', '-')
4646
.toLowerCase();
47-
elemHeading.id = newHeadingId || '';
47+
elemHeading.id = `toc-${newHeadingId}`;
4848
}
4949
// Push heading data to the permalink array
5050
permalinks.push({

sites/skeleton.dev/src/routes/(inner)/utilities/table-of-contents/+page.svelte

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@
7979
code={`
8080
<!-- Before: -->
8181
<h2 class="h2">Title One</h2>
82-
<h2 class="h2" id="my-custom-id">Title Two</h2>\n
82+
<h2 class="h2" id="toc-my-custom-id">Title Two</h2>\n
8383
<!-- After: -->
8484
<h2 class="h2" id="title-one">Title One</h2>
8585
<h2 class="h2" id="my-custom-id">Title Two</h2>

0 commit comments

Comments
 (0)