mirror of
https://github.com/RGBCube/Site
synced 2025-07-30 20:47:46 +00:00
headers: make them actually have unique IDs
This commit is contained in:
parent
e799cc1c45
commit
c96c59ecf5
1 changed files with 1 additions and 5 deletions
6
site.ts
6
site.ts
|
@ -70,8 +70,6 @@ site.process([".html"], (pages) => {
|
|||
wrapper.appendChild(element);
|
||||
});
|
||||
|
||||
const encountered: Record<string, boolean> = {};
|
||||
|
||||
document
|
||||
.querySelectorAll(".text-content :where(h1, h2, h3, h4, h5, h6)")
|
||||
.forEach((header) => {
|
||||
|
@ -90,13 +88,11 @@ site.process([".html"], (pages) => {
|
|||
let textUnique = textNormalized;
|
||||
let counter = 1;
|
||||
|
||||
while (encountered[textUnique]) {
|
||||
while (document.getElementById(textUnique)) {
|
||||
counter++;
|
||||
textUnique = `${textNormalized}-${counter}`;
|
||||
}
|
||||
|
||||
encountered[textUnique] = true;
|
||||
|
||||
header.id = textUnique;
|
||||
|
||||
const link = document.createElement("a");
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue