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 { title } = status
48 if (title) a.textContent = title.length
> 28
49 ?
"".concat(...title.slice(
0,
27),
"…")
52 const summaryText = (() =
> {
54 const d = parser.parseFromString(status.content,
"application/xhtml+xml")
55 const div = document.createElement(
"div")
56 div.appendChild(document.importNode(d.documentElement, true))
57 Object.assign(div.style,
58 { position:
"absolute"
62 , overflow:
"hidden" })
63 document.body.appendChild(div)
64 const text = div.innerText
65 document.body.removeChild(div)
68 const chars = Array.from(summaryText.trim().replaceAll(/\s+/gu,
" "))
69 a.textContent = chars.length
> 28
70 ?
"".concat(...chars.slice(
0,
27),
"…")
71 : summaryText || status.identifier } }
74 .appendChild(document.createElement(
"p"))
75 .appendChild(document.createElement(
"a"))
77 a.textContent =
"Next Page" }
78 if (current && current != location && current != next) {
80 .appendChild(document.createElement(
"p"))
81 .appendChild(document.createElement(
"a"))
83 a.textContent =
"Latest Page" } })