dotfiles
My PC Dotfiles & Websitegit clone https://github.com/maydayv7/dotfiles
site/static/js/footnote.js (754B)
1window.addEventListener("load", function () {
2 for (const ref of document.getElementsByClassName("footnote-reference")) {
3 const hash = ref.children[0].hash.substring(1);
4 const refhash = "ref:" + hash;
5 ref.id = refhash;
6 }
7
8 for (const footnote of document.getElementsByClassName(
9 "footnote-definition",
10 )) {
11 const hash = footnote.id;
12 const refhash = "ref:" + hash;
13 const backlink = document.createElement("a");
14 backlink.href = "#" + refhash;
15 backlink.className = "backlink";
16 backlink.innerText = "↩";
17 backlink.setAttribute("aria-label", "Back to footnote reference " + hash);
18 const paras = footnote.children;
19 const lastPara = paras[paras.length - 1];
20 lastPara.appendChild(backlink);
21 }
22});