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 }
10 const nav = document.body.querySelector("nav")
11 const dl = nav.querySelector("dl")
12 const parser = new DOMParser
13 fetch(`${location}.jsonld`)
16 const topic = meta.subject || meta["@id"].split("/").pop()
17 document.title = topic
18 document.body.querySelector("h1").textContent = "subject" in meta
21 const { first, prev, next, current, items } = meta
22 if (first && first != location && first != prev) {
24 .insertBefore(document.createElement("p"), dl)
25 .appendChild(document.createElement("a"))
27 a.textContent = "First Page" }
30 .insertBefore(document.createElement("p"), dl)
31 .appendChild(document.createElement("a"))
33 a.textContent = "Previous Page" }
34 let prevDate = undefined
35 for (const status of items) {
36 if (status.created != prevDate) dl.appendChild(document.createElement("dt")).textContent = status.created
38 .appendChild(document.createElement("dd"))
39 .appendChild(document.createElement("a"))
40 a.href = status["@id"]
41 const summaryText = (() =
> {
43 const d = parser.parseFromString(status.content, "application/xhtml+xml")
44 const div = document.createElement("div")
45 div.appendChild(document.importNode(d.documentElement, true))
46 Object.assign(div.style,
47 { position: "absolute"
51 , overflow: "hidden" })
52 document.body.appendChild(div)
53 const text = div.innerText
54 document.body.removeChild(div)
57 const chars = Array.from(summaryText.trim().replaceAll(/\s+/gu, " "))
58 a.textContent = chars.length
> 28
59 ?
"".concat(...chars.slice(
0,
27),
"…")
60 : summaryText || status.identifier }
63 .appendChild(document.createElement(
"p"))
64 .appendChild(document.createElement(
"a"))
66 a.textContent =
"Next Page" }
67 if (current && current != location && current != next) {
69 .appendChild(document.createElement(
"p"))
70 .appendChild(document.createElement(
"a"))
72 a.textContent =
"Latest Page" } })