X-Git-Url: https://git.ladys.computer/x_status_git/blobdiff_plain/ba9160c0bfb50ccb17613c15a95a28a3880fde32..6b8de961c3f0e23435afe54d072951d9dd007f79:/topic.html diff --git a/topic.html b/topic.html index ea9b384..f0a4a9e 100644 --- a/topic.html +++ b/topic.html @@ -10,12 +10,6 @@ body{ Display: Grid; Box-Sizing: Border-Box; Margin: Auto; Padding-Inline: 1REM; const nav = document.body.querySelector("nav") const dl = nav.querySelector("dl") const parser = new DOMParser -if (location.pathname.startsWith("/topics/")) { - const a = nav - .insertBefore(document.createElement("p"), dl) - .appendChild(document.createElement("a")) - a.href = "/topics/" - a.textContent = "Topics" } fetch(`${location}.jsonld`) .then($ => $.json()) .then(meta => { @@ -24,6 +18,12 @@ fetch(`${location}.jsonld`) document.body.querySelector("h1").textContent = "subject" in meta ? `#${topic}` : `@${topic}` + if ("subject" in meta) { + const a = nav + .insertBefore(document.createElement("p"), dl) + .appendChild(document.createElement("a")) + a.href = "/topics" + a.textContent = "Topics" } const { first, prev, next, current, items } = meta if (first && first != location && first != prev) { const a = nav @@ -44,26 +44,31 @@ fetch(`${location}.jsonld`) .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 } + 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"))