diff --git a/functions/s/[id].js b/functions/s/[id].js
index e9fa10a..f47596f 100644
--- a/functions/s/[id].js
+++ b/functions/s/[id].js
@@ -17,6 +17,31 @@ function duration(ms) {
return `${Math.floor(s / 60)}:${String(s % 60).padStart(2, "0")}`;
}
+// A chapter line of a description: `00:00 Intro`, `1:02:03 Wrap-up`.
+const CHAPTER = /^((?:\d{1,2}:)?\d{1,2}:\d{2})\s+(.+)$/;
+const seconds = (t) => t.split(":").reduce((n, p) => n * 60 + Number(p), 0);
+
+// The description as HTML: paragraphs, and chapter lines as times that jump the player there.
+function describe(text) {
+ const blocks = String(text ?? "").trim().split(/\n\s*\n/).filter((b) => b.trim());
+ return blocks.map((block) => {
+ const lines = block.split("\n").map((l) => l.trim()).filter(Boolean);
+ const chapters = lines.filter((l) => CHAPTER.test(l));
+ if (chapters.length >= 2 && chapters.length >= lines.length - 1) {
+ const head = lines.length > chapters.length ? `
${esc(lines.find((l) => !CHAPTER.test(l)))}
` : "";
+ const items = chapters.map((l) => { const [, t, name] = l.match(CHAPTER); return `${esc(t)}${esc(name)}`; }).join("");
+ return `${head}${items}
`;
+ }
+ return `${lines.map(esc).join("
")}
`;
+ }).join("");
+}
+
+// The description's opening, for link previews (no chapter list).
+function summary(text) {
+ const prose = String(text ?? "").split("\n").map((l) => l.trim()).filter((l) => l && !CHAPTER.test(l) && l !== "Chapters").join(" ");
+ return prose.length > 200 ? prose.slice(0, 197).replace(/\s+\S*$/, "") + "…" : prose;
+}
+
const STYLE = `
:root{--ground:#15161e;--ink:#1e1f29;--line:rgba(248,248,242,.10);--fg:#c9cbdc;--white:#f8f8f2;--dim:#8e90a6;--accent:#ff8a5c;--on-accent:#1e1f29;color-scheme:dark}
@media (prefers-color-scheme:light){:root{--ground:#ececf1;--ink:#f6f6fa;--line:rgba(30,31,41,.12);--fg:#2e2f3b;--white:#1a1b24;--dim:#5f6175;--accent:#d4442a;--on-accent:#fff;color-scheme:light}}
@@ -34,6 +59,15 @@ h1{color:var(--white);font-size:22px;font-weight:600;letter-spacing:-.01em;margi
.meta{color:var(--dim);font-size:13.5px;display:flex;gap:14px;flex-wrap:wrap;align-items:center}
.row{display:flex;justify-content:space-between;align-items:flex-start;gap:16px;flex-wrap:wrap}
.actions{display:flex;gap:8px;margin-top:18px}
+.about{max-width:760px;margin-top:18px;color:var(--fg);font-size:15px}
+.about p{margin-bottom:12px;overflow-wrap:anywhere}
+.about h2{color:var(--white);font-size:14px;font-weight:600;margin:6px 0 6px}
+.chapters{list-style:none;margin-bottom:12px}
+.chapters li{display:flex;gap:12px;padding:3px 0}
+.chapters a{color:var(--accent);text-decoration:none;font-variant-numeric:tabular-nums;min-width:52px}
+.chapters a:hover{text-decoration:underline}
+.tags{display:flex;flex-wrap:wrap;gap:6px;margin-top:4px}
+.tags span{color:var(--dim);font-size:12.5px;border:1px solid var(--line);border-radius:2px;padding:2px 8px}
footer{margin-top:auto;padding-top:40px;padding-bottom:28px;color:var(--dim);font-size:13px;text-align:center}
footer a{color:var(--fg)}
.gone{text-align:center;padding:18vh 0}
@@ -94,12 +128,16 @@ async function render(id) {
return new Response("This video could not be loaded. Try again in a moment.", { status: 502 });
}
const title = s.title || "Screen recording";
+ const about = summary(s.description);
+ const tags = Array.isArray(s.tags) ? s.tags.filter((t) => typeof t === "string" && t) : [];
const date = s.created_at ? new Date(s.created_at).toLocaleDateString("en-US", { year: "numeric", month: "short", day: "numeric" }) : "";
const og = [
``,
``,
``,
``,
+ about ? `` : "",
+ tags.length ? `` : "",
``,
``,
``,
@@ -115,6 +153,7 @@ async function render(id) {
${esc(title)}
${[date, duration(s.duration_ms), views].filter(Boolean).map(esc).join("·")}
+${s.description || tags.length ? `${describe(s.description)}${tags.length ? `${tags.map((t) => `${esc(t)}`).join("")}
` : ""}` : ""}
${esc(String(s.url).replace(/^https?:\/\//, ""))}
@@ -133,6 +172,10 @@ async function render(id) {
document.getElementById("qr").onclick=open;
view.onclick=close;document.addEventListener("keydown",function(e){if(e.key==="Escape")close()});
})();
+// chapter times jump the player (and #t=… in the address starts there)
+(function(){var v=document.querySelector("video");if(!v)return;function go(t){v.currentTime=t;v.play().catch(function(){});v.scrollIntoView({behavior:"smooth",block:"center"})}
+document.querySelectorAll(".chapters a").forEach(function(a){a.onclick=function(e){e.preventDefault();go(Number(a.dataset.t));history.replaceState(null,"","#t="+a.dataset.t)}});
+var m=location.hash.match(/^#t=(\d+)$/);if(m)v.addEventListener("loadedmetadata",function(){v.currentTime=Number(m[1])},{once:true})})();
document.getElementById("copy").onclick=function(){var b=this;navigator.clipboard.writeText(${JSON.stringify(s.url)}).then(function(){b.textContent="Copied";setTimeout(function(){b.textContent="Copy link"},1500)})};
try{fetch(${JSON.stringify(`${SUPABASE_URL}/functions/v1/share`)},{method:"POST",keepalive:true,headers:{apikey:${JSON.stringify(SUPABASE_ANON_KEY)},Authorization:"Bearer "+${JSON.stringify(SUPABASE_ANON_KEY)},"Content-Type":"application/json"},body:JSON.stringify({action:"view",id:${JSON.stringify(id)}})})}catch(e){}
`;