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 }
6 article{ Font-Size: Larger }
7 summary{ Padding-Block:
1REM; Font-Weight: Bold }
8 details[open]
>summary{ Border-Block-End: Thin Solid }
9 header{ Border-Block-End: Thin Solid; Padding-Block:
1REM; Text-Align: Start }
10 footer{ Border-Block-Start: Thin Solid; Padding-Block:
1REM; Text-Align: End }
11 footer p{ Margin-Block:
0 .5REM }
12 footer time:Not([datetime]),
13 footer small{ Font-Size: Inherit; Font-Style: Italic }
17 const parser = new DOMParser
18 fetch(`${new URL(
".", location).toString().slice(
0, -
1)}.jsonld`)
21 const { items, subject } = meta
22 const n = items.findIndex($ =
> new URL($[
"@id"]).pathname === location.pathname)
23 const status = items[n]
24 const src = status.content
25 const { documentElement: article } = parser.parseFromString(src,
"application/xhtml+xml")
26 const { creator, created, title } = status
27 document.title = creator
28 ? `Status by ${creator.name} @ ${status.created}`
29 : `Status @ ${created}`
30 const header = document.createElement(
"header")
31 const footer = document.createElement(
"footer")
32 const headerChildren =
36 subjectLink.textContent = subject
37 subjectLink.href = meta[
"@id"]
38 return subjectLink })(document.createElement(
"a"))
42 const authorLink = document.createElement(
"@id" in creator ?
"a" :
"span")
43 if (authorLink.localName ==
"a") authorLink.href = creator[
"@id"]
44 authorLink.textContent = creator.name
45 headerChildren.push(
" by ", authorLink,
"…") }
46 else headerChildren.push(
"…")
47 header.append(...headerChildren)
48 const timestampP = footer.appendChild(document.createElement(
"p"))
49 timestampP.appendChild(document.createElement(
"time")).textContent = created
51 .appendChild(document.createElement(
"p"))
52 .appendChild(document.createElement(
"small"))
53 .textContent = status.identifier
54 const nav = footer.appendChild(document.createElement(
"nav"))
55 nav.appendChild(document.createTextNode(
"Up: "))
56 const upLink = nav.appendChild(document.createElement(
"a"))
57 upLink.href = meta[
"@id"]
58 upLink.textContent = meta.subject || meta[
"@id"].split(
"/").pop()
60 nav.appendChild(document.createTextNode(
"; Previous: "))
61 const prevLink = nav.appendChild(document.createElement(
"a"))
62 prevLink.href = items[n -
1][
"@id"]
63 const prevText = (() =
> {
65 const prevD = parser.parseFromString(items[n -
1].content,
"application/xhtml+xml")
66 const div = document.createElement(
"div")
67 div.appendChild(document.importNode(prevD.documentElement, true))
68 Object.assign(div.style,
69 { position:
"absolute"
73 , overflow:
"hidden" })
74 document.body.appendChild(div)
75 const text = div.innerText
76 document.body.removeChild(div)
78 catch { } })() ?? items[n +
1].created;
79 const prevChars = Array.from(prevText.trim().replaceAll(/\s+/gu,
" "))
80 prevLink.textContent = prevChars.length
> 28
81 ?
"".concat(...prevChars.slice(
0,
27),
"…")
83 if (n < items.length -
1) {
84 nav.appendChild(document.createTextNode(
"; Next: "))
85 const nextLink = nav.appendChild(document.createElement(
"a"))
86 nextLink.href = items[n +
1][
"@id"]
87 const nextText = (() =
> {
89 const nextD = parser.parseFromString(items[n +
1].content,
"application/xhtml+xml")
90 const div = document.createElement(
"div")
91 div.appendChild(document.importNode(nextD.documentElement, true))
92 Object.assign(div.style,
93 { position:
"absolute"
97 , overflow:
"hidden" })
98 document.body.appendChild(div)
99 const text = div.innerText
100 document.body.removeChild(div)
102 catch { } })() ?? items[n +
1].created;
103 const nextChars = Array.from(nextText.trim().replaceAll(/\s+/gu,
" "))
104 nextLink.textContent = nextChars.length
> 28
105 ?
"".concat(...nextChars.slice(
0,
27),
"…")
107 nav.appendChild(document.createTextNode(
"."))
109 const wrapper = document.createElement(
"article")
110 const details = wrapper.appendChild(document.createElement(
"details"))
111 details.setAttribute(
"open",
"")
112 const summary = details.appendChild(document.createElement(
"summary"))
113 summary.textContent = title
114 details.append(...document.importNode(article, true).childNodes)
115 document.body.replaceChildren(header, wrapper, footer) }
116 else document.body.replaceChildren(header, document.importNode(article, true), footer) })