diff options
| author | Collin Williams <96917990+bluedragon1221@users.noreply.github.com> | 2026-09-19 21:13:32 -0500 |
|---|---|---|
| committer | Collin Williams <96917990+bluedragon1221@users.noreply.github.com> | 2026-09-19 21:13:32 -0500 |
| commit | b6f7b9dda8cd2e4b1c5b006ad5866d3ef7e62310 (patch) | |
| tree | cea3af7c287c28fcaf379ec3700f0aa76223e244 /article.js | |
| parent | ffd6abb1403d85b61c80fc8d23a3a04df8895c20 (diff) | |
inserting link:css via javascript was a bad idea
Diffstat (limited to 'article.js')
| -rw-r--r-- | article.js | 93 |
1 files changed, 0 insertions, 93 deletions
diff --git a/article.js b/article.js deleted file mode 100644 index ecf2d40..0000000 --- a/article.js +++ /dev/null @@ -1,93 +0,0 @@ -function addMetadata() { - // Favicon - const favicon = document.createElement("link"); - favicon.rel = "icon"; - favicon.href = "static/Logo.svg"; - favicon.type = "image/svg+xml"; - document.head.appendChild(favicon); - - // UTF-8 (for special characters) - const charset = document.createElement("meta"); - charset.setAttribute("charset", "UTF-8"); - document.head.appendChild(charset); - - // viewport (for mobile) - const viewport = document.createElement("meta"); - viewport.setAttribute("name", "viewport"); - viewport.setAttribute("content", "width=device-width, initial-scale=1.0"); - document.head.appendChild(viewport); - - // css - const proseCss = document.createElement("link"); - proseCss.rel = "stylesheet"; - proseCss.href = "article.css"; - document.head.appendChild(proseCss); -} - -function addHeader() { - const header = document.querySelector("header"); - - const headerTop = document.createElement("div"); - headerTop.classList.add("header-top"); - - const logoLink = document.createElement("a"); - logoLink.href = "writing"; - logoLink.classList.add("header-logo-link"); - headerTop.appendChild(logoLink); - - const info = document.createElement("div"); - info.classList.add("header-info"); - const h1 = document.createElement("h1"); - h1.textContent = document.title; - info.appendChild(h1); - const time = document.createElement("time"); - const metaDate = document.querySelector('meta[property="article:published_time"]'); - const dateString = metaDate.getAttribute("content"); - const displayDate = (new Date(dateString)).toLocaleDateString("en-US", { - month: "short", - day: "numeric", - year: "numeric", - timeZone: "UTC" - }); - time.setAttribute("datetime", dateString); - time.textContent = `Published ${displayDate}`; - info.appendChild(time); - headerTop.appendChild(info); - header.appendChild(headerTop); - - const hr = document.createElement("hr"); - header.appendChild(hr); -} - -function addTOC() { - const tocDiv = document.getElementById("toc"); - if (!tocDiv) return; - - const tocHeading = document.createElement("h2"); - tocHeading.textContent = "Table of Contents"; - tocDiv.appendChild(tocHeading); - - const toc = document.createElement("ul"); - - document.querySelectorAll('article :is(h1, h2, h3, h4, h5, h6):not(header *, #toc *)').forEach(heading => { - const link = document.createElement("a"); - link.href = "#" + heading.id.toLowerCase(); - link.textContent = heading.textContent; - - const li = document.createElement("li"); - li.appendChild(link); - - toc.appendChild(li); - }); - - tocDiv.appendChild(toc); -} - -document.addEventListener("DOMContentLoaded", () => { - addMetadata(); - addHeader(); - addTOC(); - - const article = document.querySelector('article'); - article.classList.add('markdown-body'); -}) |
