We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 11a188e commit 01542bcCopy full SHA for 01542bc
apps/www/src/lib/components/docs/table-of-contents.svelte
@@ -18,13 +18,20 @@
18
const hierarchy: TableOfContents = { items: [] };
19
let currentLevel: TableOfContentsItem | undefined = undefined;
20
21
+ const newIdSet: Set<string> = new Set();
22
+ let count = 1;
23
headings.forEach((heading: HTMLHeadingElement) => {
24
const level = parseInt(heading.tagName.charAt(1));
25
if (!heading.id) {
26
let newId = heading.innerText
27
.replaceAll(/[^a-zA-Z0-9 ]/g, "")
28
.replaceAll(" ", "-")
29
.toLowerCase();
30
+ if (newIdSet.has(newId)) {
31
+ newId = `${newId}-${count}`;
32
+ count++;
33
+ }
34
+ newIdSet.add(newId);
35
heading.id = `${newId}`;
36
}
37
0 commit comments