X-Git-Url: https://git.ladys.computer/x_status_git/blobdiff_plain/2659b92ca7ae70783227a5de0c000e34b984e2c2..6b8de961c3f0e23435afe54d072951d9dd007f79:/topic.html diff --git a/topic.html b/topic.html index 17cb96e..f0a4a9e 100644 --- a/topic.html +++ b/topic.html @@ -5,7 +5,7 @@ body{ Display: Grid; Box-Sizing: Border-Box; Margin: Auto; Padding-Inline: 1REM; Min-Block-Size: 100VH; Inline-Size: 100%; Max-Inline-Size: 45REM; Align-Content: Center; Justify-Content: Stretch; Font-Family: Sans-Serif } </STYLE> <H1>Topic Feed</H1> -<NAV><DL></DL></NAV> +<NAV><P><A HRef=/>Home</A></P><DL></DL></NAV> <SCRIPT Type=module> const nav = document.body.querySelector("nav") const dl = nav.querySelector("dl") @@ -18,55 +18,67 @@ fetch(`${location}.jsonld`) document.body.querySelector("h1").textContent = "subject" in meta ? `#${topic}` : `@${topic}` - if (meta.first != location) { + if ("subject" in meta) { const a = nav .insertBefore(document.createElement("p"), dl) .appendChild(document.createElement("a")) - a.href = meta.first + a.href = "/topics" + a.textContent = "Topics" } + const { first, prev, next, current, items } = meta + if (first && first != location && first != prev) { + const a = nav + .insertBefore(document.createElement("p"), dl) + .appendChild(document.createElement("a")) + a.href = first a.textContent = "First Page" } - if (meta.prev && meta.prev != meta.first) { + if (prev) { const a = nav .insertBefore(document.createElement("p"), dl) .appendChild(document.createElement("a")) - a.href = meta.prev + a.href = prev a.textContent = "Previous Page" } let prevDate = undefined - for (const status of meta.items) { + for (const status of items) { if (status.created != prevDate) dl.appendChild(document.createElement("dt")).textContent = status.created const a = dl .appendChild(document.createElement("dd")) .appendChild(document.createElement("a")) a.href = status["@id"] - const summaryText = (() => { - try { - const d = parser.parseFromString(status.content, "application/xhtml+xml") - const div = document.createElement("div") - div.appendChild(document.importNode(d.documentElement, true)) - Object.assign(div.style, - { position: "absolute" - , top: "-2px" - , height: "1px" - , width: "1px" - , overflow: "hidden" }) - document.body.appendChild(div) - const text = div.innerText - document.body.removeChild(div) - return text } - catch { } })() || ""; - const chars = Array.from(summaryText.trim().replaceAll(/\s+/gu, " ")) - a.textContent = chars.length > 28 - ? "".concat(...chars.slice(0, 27), "…") - : summaryText || status.identifier } - if (meta.next && meta.next != meta.current) { + const { title } = status + if (title) a.textContent = title.length > 28 + ? "".concat(...title.slice(0, 27), "…") + : title + else { + const summaryText = (() => { + try { + const d = parser.parseFromString(status.content, "application/xhtml+xml") + const div = document.createElement("div") + div.appendChild(document.importNode(d.documentElement, true)) + Object.assign(div.style, + { position: "absolute" + , top: "-2px" + , height: "1px" + , width: "1px" + , overflow: "hidden" }) + document.body.appendChild(div) + const text = div.innerText + document.body.removeChild(div) + return text } + catch { } })() || ""; + const chars = Array.from(summaryText.trim().replaceAll(/\s+/gu, " ")) + a.textContent = chars.length > 28 + ? "".concat(...chars.slice(0, 27), "…") + : summaryText || status.identifier } } + if (next) { const a = nav .appendChild(document.createElement("p")) .appendChild(document.createElement("a")) - a.href = meta.next + a.href = next a.textContent = "Next Page" } - if (meta.current != location) { + if (current && current != location && current != next) { const a = nav .appendChild(document.createElement("p")) .appendChild(document.createElement("a")) - a.href = meta.current + a.href = current a.textContent = "Latest Page" } }) </SCRIPT>