1
Fork 0
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:
RGBCube 2025-06-02 23:20:57 +03:00
parent e799cc1c45
commit c96c59ecf5
Signed by: RGBCube
SSH key fingerprint: SHA256:CzqbPcfwt+GxFYNnFVCqoN5Itn4YFrshg1TrnACpA5M

View file

@ -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");