diff --git a/site.ts b/site.ts
index 7b59c63..66a926f 100644
--- a/site.ts
+++ b/site.ts
@@ -89,7 +89,7 @@ site.process([".html"], (pages) => {
let counter = 1;
while (document.getElementById(textUnique)) {
- counter++;
+ counter += 1;
textUnique = `${textNormalized}-${counter}`;
}
@@ -101,6 +101,60 @@ site.process([".html"], (pages) => {
header.parentNode!.insertBefore(link, header);
link.appendChild(header);
});
+
+ const footnotes = document.querySelector("#footnotes");
+ if (footnotes) {
+ let counter = 0;
+
+ document.querySelectorAll("p").forEach((paragraph) => {
+ const matches = paragraph.innerHTML.match(/\[\^([^\]]*)\]/g);
+ if (!matches) return;
+
+ let newHTML = paragraph.innerHTML;
+
+ matches.forEach((match) => {
+ const footnoteText = match.slice(2, -1);
+
+ let number;
+ let addFooter;
+
+ if (footnoteText.match(/^[1-9]+$/g)) {
+ number = parseInt(footnoteText);
+ addFooter = false;
+ } else {
+ counter += 1;
+ number = counter;
+ addFooter = true;
+ }
+
+ const anchorId = `ref:${counter}`;
+ const footnoteId = `fn:${counter}`;
+
+ const link =
+ `^${number}`;
+ newHTML = newHTML.replace(match, link);
+
+ if (addFooter) {
+ const hr = document.createElement("hr");
+ hr.classList.add("my-1.5");
+
+ const li = document.createElement("li");
+ li.id = footnoteId;
+ li.innerHTML =
+ `${footnoteText}..?`;
+
+ footnotes.appendChild(hr);
+ footnotes.appendChild(li);
+ }
+ });
+
+ paragraph.innerHTML = newHTML;
+ });
+
+ if (counter === 0) {
+ footnotes.remove();
+ }
+ }
});
});
@@ -154,12 +208,12 @@ site.use(sitemap({
site.use(lightningcss()); // TODO: LightningCSS doesn't handle inline styles.
site.use(inline());
-site.use(minifyHtml({
- options: {
- // TODO: This breaks tailwind.
- // minify_css: true,
- minify_js: true,
- },
-}));
+// site.use(minifyHtml({
+// options: {
+// // TODO: This breaks tailwind.
+// // minify_css: true,
+// minify_js: true,
+// },
+// }));
export default site;
diff --git a/site/_includes/text.vto b/site/_includes/text.vto
index a88008d..3046b9c 100644
--- a/site/_includes/text.vto
+++ b/site/_includes/text.vto
@@ -31,6 +31,8 @@ layout: default.vto
{{> const padding = 4 }}