diff --git a/index.html b/index.html index 0ad82fe7..04ac8c38 100644 --- a/index.html +++ b/index.html @@ -55,7 +55,7 @@ const path = `https://raw.githubusercontent.com/braxtonhall/library-thing/main/${md}`; - const fixLinks = () => + const fixLinks = () => { $("a").each((_, element) => { const $element = $(element); const href = $element.attr("href"); @@ -63,6 +63,15 @@ $element.attr("href", `${href}.pretty`); } }); + $("h1, h2, h3, h4").each((_, element) => { + const $element = $(element); + const text = $element.text(); + const id = text.toLowerCase() + .replace(/ /g, "-") + .replace(/[^a-z-]/g, ""); + $element.attr("id", id); + }); + }; fetch(path) .then((response) => response.text())