summaryrefslogtreecommitdiff
path: root/article.js
diff options
context:
space:
mode:
authorCollin Williams <96917990+bluedragon1221@users.noreply.github.com>2026-06-11 12:40:51 -0500
committerCollin Williams <96917990+bluedragon1221@users.noreply.github.com>2026-06-11 12:40:51 -0500
commit8d17a31bd701d7b9c90c546b29f3bf9ffa4cc41f (patch)
treeb76361859df0b9dec2517ac8aa9b5671292592b9 /article.js
parent3c1846a179cc7f7630efb2d1a85018f2be680b9c (diff)
changes to article structure, wrote about ai
Diffstat (limited to 'article.js')
-rw-r--r--article.js53
1 files changed, 53 insertions, 0 deletions
diff --git a/article.js b/article.js
new file mode 100644
index 0000000..4818a3d
--- /dev/null
+++ b/article.js
@@ -0,0 +1,53 @@
+function addTOC() {
+ var tocDiv = document.createElement("div");
+ tocDiv.classList += "toc";
+ var toc = document.createElement("ul");
+
+ document.body.querySelectorAll('h1, h2, h3, h4, h5, h6').forEach(heading => {
+ var link = document.createElement('a');
+ link.setAttribute('href', '#'+heading.id.toLowerCase());
+ link.textContent = heading.textContent;
+
+ var li = document.createElement('li');
+ li.appendChild(link);
+
+ toc.appendChild(li);
+ });
+
+ tocDiv.append(toc);
+ document.body.prepend(tocDiv);
+
+ var styleBlock = document.createElement("style");
+ styleBlock.textContent = `
+ .toc {
+ position: fixed;
+ width: 17rem;
+ top: 32px;
+ left: calc(50vw - 37.5ch - 20rem);
+ padding-right: 0.75rem;
+ z-index: 1;
+
+ ul {
+ margin: 0;
+ padding-left: 1rem;
+ line-height: 1.4;
+ }
+
+ li {
+ margin-bottom: 0.35rem;
+ font-size: 1.1rem;
+ }
+ }
+
+ @media (max-width: 1000px) {
+ .toc {
+ display: none;
+ }
+ }
+ `;
+ document.head.append(styleBlock);
+}
+
+document.addEventListener("DOMContentLoaded", () => {
+ addTOC()
+}) \ No newline at end of file