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 if (meta.first != location) {
23 .insertBefore(document.createElement(
"p"), dl)
24 .appendChild(document.createElement(
"a"))
26 a.textContent =
"First Page" }
27 if (meta.prev && meta.prev != meta.first) {
29 .insertBefore(document.createElement(
"p"), dl)
30 .appendChild(document.createElement(
"a"))
32 a.textContent =
"Previous Page" }
33 let prevDate = undefined
34 for (const status of meta.items) {
35 if (status.created != prevDate) dl.appendChild(document.createElement(
"dt")).textContent = status.created
37 .appendChild(document.createElement(
"dd"))
38 .appendChild(document.createElement(
"a"))
39 a.href = status[
"@id"]
40 const summaryText = (() =
> {
42 const d = parser.parseFromString(status.content,
"application/xhtml+xml")
43 const div = document.createElement(
"div")
44 div.appendChild(document.importNode(d.documentElement, true))
45 Object.assign(div.style,
46 { position:
"absolute"
50 , overflow:
"hidden" })
51 document.body.appendChild(div)
52 const text = div.innerText
53 document.body.removeChild(div)
56 const chars = Array.from(summaryText.trim().replaceAll(/\s+/gu,
" "))
57 a.textContent = chars.length
> 28
58 ?
"".concat(...chars.slice(
0,
27),
"…")
59 : summaryText || status.identifier }
60 if (meta.next && meta.next != meta.current) {
62 .appendChild(document.createElement(
"p"))
63 .appendChild(document.createElement(
"a"))
65 a.textContent =
"Next Page" }
66 if (meta.current != location) {
68 .appendChild(document.createElement(
"p"))
69 .appendChild(document.createElement(
"a"))
71 a.textContent =
"Latest Page" } })