3 <TITLE>Topic Feed
</TITLE>
5 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 }
8 <NAV><P><A HRef=
/>Home
</A></P><DL></DL></NAV>
10 const nav = document.body.querySelector("nav")
11 const dl = nav.querySelector("dl")
12 const parser = new DOMParser
13 if (location.pathname.startsWith("/topics/")) {
15 .insertBefore(document.createElement("p"), dl)
16 .appendChild(document.createElement("a"))
18 a.textContent = "Topics" }
19 fetch(`${location}.jsonld`)
22 const topic = meta.subject || meta["@id"].split("/").pop()
23 document.title = topic
24 document.body.querySelector("h1").textContent = "subject" in meta
27 const { first, prev, next, current, items } = meta
28 if (first && first != location && first != prev) {
30 .insertBefore(document.createElement("p"), dl)
31 .appendChild(document.createElement("a"))
33 a.textContent = "First Page" }
36 .insertBefore(document.createElement("p"), dl)
37 .appendChild(document.createElement("a"))
39 a.textContent = "Previous Page" }
40 let prevDate = undefined
41 for (const status of items) {
42 if (status.created != prevDate) dl.appendChild(document.createElement("dt")).textContent = status.created
44 .appendChild(document.createElement("dd"))
45 .appendChild(document.createElement("a"))
46 a.href = status["@id"]
47 const summaryText = (() =
> {
49 const d = parser.parseFromString(status.content, "application/xhtml+xml")
50 const div = document.createElement("div")
51 div.appendChild(document.importNode(d.documentElement, true))
52 Object.assign(div.style,
53 { position: "absolute"
57 , overflow: "hidden" })
58 document.body.appendChild(div)
59 const text = div.innerText
60 document.body.removeChild(div)
63 const chars = Array.from(summaryText.trim().replaceAll(/\s+/gu, " "))
64 a.textContent = chars.length
> 28
65 ?
"".concat(...chars.slice(
0,
27),
"…")
66 : summaryText || status.identifier }
69 .appendChild(document.createElement(
"p"))
70 .appendChild(document.createElement(
"a"))
72 a.textContent =
"Next Page" }
73 if (current && current != location && current != next) {
75 .appendChild(document.createElement(
"p"))
76 .appendChild(document.createElement(
"a"))
78 a.textContent =
"Latest Page" } })