]> Lady’s Gitweb - x_status_git/blobdiff - topic.html
Support titles on statuses
[x_status_git] / topic.html
index ff648db32c34ef33e0fa365e9b749303a14c0dd4..3a08a135ba5a10df19d03074871fc947c5f3b3b0 100644 (file)
@@ -5,11 +5,17 @@
 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 }
 </STYLE>
 <H1>Topic Feed</H1>
-<NAV><DL></DL></NAV>
+<NAV><P><A HRef=/>Home</A></P><DL></DL></NAV>
 <SCRIPT Type=module>
 const nav = document.body.querySelector("nav")
 const dl = nav.querySelector("dl")
 const parser = new DOMParser
+if (location.pathname.startsWith("/topics/")) {
+  const a = nav
+  .insertBefore(document.createElement("p"), dl)
+  .appendChild(document.createElement("a"))
+  a.href = "/topics/"
+  a.textContent = "Topics" }
 fetch(`${location}.jsonld`)
 .then($ => $.json())
 .then(meta => {
@@ -38,26 +44,31 @@ fetch(`${location}.jsonld`)
     .appendChild(document.createElement("dd"))
     .appendChild(document.createElement("a"))
     a.href = status["@id"]
-    const summaryText = (() => {
-      try {
-        const d = parser.parseFromString(status.content, "application/xhtml+xml")
-        const div = document.createElement("div")
-        div.appendChild(document.importNode(d.documentElement, true))
-        Object.assign(div.style,
-          { position: "absolute"
-          , top: "-2px"
-          , height: "1px"
-          , width: "1px"
-          , overflow: "hidden" })
-        document.body.appendChild(div)
-        const text = div.innerText
-        document.body.removeChild(div)
-        return text }
-      catch { } })() || "";
-    const chars = Array.from(summaryText.trim().replaceAll(/\s+/gu, " "))
-    a.textContent = chars.length > 28
-    ? "".concat(...chars.slice(0, 27), "…")
-    : summaryText || status.identifier }
+    const { title } = status
+    if (title) a.textContent = title.length > 28
+    ? "".concat(...title.slice(0, 27), "…")
+    : title
+    else {
+      const summaryText = (() => {
+        try {
+          const d = parser.parseFromString(status.content, "application/xhtml+xml")
+          const div = document.createElement("div")
+          div.appendChild(document.importNode(d.documentElement, true))
+          Object.assign(div.style,
+            { position: "absolute"
+            , top: "-2px"
+            , height: "1px"
+            , width: "1px"
+            , overflow: "hidden" })
+          document.body.appendChild(div)
+          const text = div.innerText
+          document.body.removeChild(div)
+          return text }
+        catch { } })() || "";
+      const chars = Array.from(summaryText.trim().replaceAll(/\s+/gu, " "))
+      a.textContent = chars.length > 28
+      ? "".concat(...chars.slice(0, 27), "…")
+      : summaryText || status.identifier } }
   if (next) {
     const a = nav
     .appendChild(document.createElement("p"))
This page took 0.022282 seconds and 4 git commands to generate.