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 footer{ Border-Block-Start: Thin Solid; Padding-Block:
1REM; Text-Align: End }
8 footer p{ Margin-Block:
0 .5REM }
9 footer time:Not([datetime]),
10 footer small{ Font-Size: Inherit; Font-Style: Italic }
14 const parser = new DOMParser
15 fetch(`${new URL(
".", location).toString().slice(
0, -
1)}.jsonld`)
18 const { items } = meta
19 const n = items.findIndex($ =
> new URL($[
"@id"]).pathname === location.pathname)
20 const status = items[n]
21 const src = status.content
22 const { documentElement: article } = parser.parseFromString(src,
"application/xhtml+xml")
23 const { creator, created } = status
24 document.title = creator
25 ? `Status by ${creator.name} @ ${status.created}`
26 : `Status @ ${created}`
27 const footer = document.createElement(
"footer")
28 const authorshipP = footer.appendChild(document.createElement(
"p"))
30 const authorLink = authorshipP.appendChild(document.createElement(
"a"))
31 authorLink.href = creator[
"@id"]
32 authorLink.textContent = creator.name
33 authorshipP.appendChild(document.createTextNode(
" @ ")) }
34 authorshipP.appendChild(document.createElement(
"time")).textContent = created
36 .appendChild(document.createElement(
"p"))
37 .appendChild(document.createElement(
"small"))
38 .textContent = status.identifier
39 const nav = footer.appendChild(document.createElement(
"nav"))
40 nav.appendChild(document.createTextNode(
"Up: "))
41 const upLink = nav.appendChild(document.createElement(
"a"))
42 upLink.href = meta[
"@id"]
43 upLink.textContent = meta.subject || meta[
"@id"].split(
"/").pop()
45 nav.appendChild(document.createTextNode(
"; Previous: "))
46 const prevLink = nav.appendChild(document.createElement(
"a"))
47 prevLink.href = items[n -
1][
"@id"]
48 const prevText = (() =
> {
50 const prevD = parser.parseFromString(items[n -
1].content,
"application/xhtml+xml")
51 const div = document.createElement(
"div")
52 div.appendChild(document.importNode(prevD.documentElement, true))
53 Object.assign(div.style,
54 { position:
"absolute"
58 , overflow:
"hidden" })
59 document.body.appendChild(div)
60 const text = div.innerText
61 document.body.removeChild(div)
63 catch { } })() ?? items[n +
1].created;
64 const prevChars = Array.from(prevText.trim().replaceAll(/\s+/gu,
" "))
65 prevLink.textContent = prevChars.length
> 28
66 ?
"".concat(...prevChars.slice(
0,
27),
"…")
68 if (n < items.length -
1) {
69 nav.appendChild(document.createTextNode(
"; Next: "))
70 const nextLink = nav.appendChild(document.createElement(
"a"))
71 nextLink.href = items[n +
1][
"@id"]
72 const nextText = (() =
> {
74 const nextD = parser.parseFromString(items[n +
1].content,
"application/xhtml+xml")
75 const div = document.createElement(
"div")
76 div.appendChild(document.importNode(nextD.documentElement, true))
77 Object.assign(div.style,
78 { position:
"absolute"
82 , overflow:
"hidden" })
83 document.body.appendChild(div)
84 const text = div.innerText
85 document.body.removeChild(div)
87 catch { } })() ?? items[n +
1].created;
88 const nextChars = Array.from(nextText.trim().replaceAll(/\s+/gu,
" "))
89 nextLink.textContent = nextChars.length
> 28
90 ?
"".concat(...nextChars.slice(
0,
27),
"…")
92 nav.appendChild(document.createTextNode(
"."))
93 document.body.replaceChildren(document.importNode(article, true), footer) })