diff --git a/src/web/client.ts b/src/web/client.ts index a26bc182f0..bb4e50bb00 100644 --- a/src/web/client.ts +++ b/src/web/client.ts @@ -956,6 +956,15 @@ function changelogCatOf(rawLine) { // keep the stale paint; the cache keeps its old timestamp, so the next visit retries }).then(function () { blogRefreshBusy = false; }); } + // Per-post discussion thread: the thread number is data, not inference — it reaches + // the client as item.discussion once the server-side passthrough lands (separate PR, + // see PR body) and the pipeline records a number for the post. Exact direct link only; + // a post without a recorded number simply shows no button (no guessed search URL). + function blogDiscussionUrl(item) { + return (typeof item.discussion === "number" && item.discussion > 0) + ? "https://github.com/ranxianglei/billion-context/discussions/" + item.discussion + : null; + } async function loadBlog(sub) { const host = $("bl-list"); if (!host) return; @@ -985,7 +994,13 @@ function changelogCatOf(rawLine) { const kindLabel = item.kind === "post" ? t("bl.kind_post") : t("bl.kind_article"); const title = zhOn && item.titleZh ? item.titleZh : (item.title || ""); const html = zhOn ? (item.htmlZh || item.html || "") : (item.html || ""); - host.innerHTML = offlineNote + '
hi
", htmlZh: "你好
" }] }; +const FEED = { items: [{ id: "demo", kind: "post", date: "2026-10-08", title: "Demo post", titleZh: "演示", excerpt: "ex", html: "hi
", htmlZh: "你好
", discussion: 123 }] }; // #4957: blog slugs keep whatever the filename carried after the date prefix // (blogfeed.ts strips only `YYYY-MM-DD_`), so ids can contain dots, spaces and @@ -113,6 +113,19 @@ test("#/blog/hi
") || list.innerHTML.includes("\u4f60\u597d")), "article body rendered (locale-twin aware)"); assert.ok(list.innerHTML.includes(''), "back link to the index present"); + // #5396 final form: exact discussion link built from the manifest-recorded number + // (item.discussion) — no search guesswork; plus the in-page EN|中文 language pins. + assert.ok(list.innerHTML.includes('href="https://github.com/ranxianglei/billion-context/discussions/123" target="_blank" rel="noopener"'), "exact discussion-thread link from the recorded number"); + assert.ok(list.innerHTML.includes("?lang=en#/blog/demo") && list.innerHTML.includes("?lang=zh#/blog/" + encodeURIComponent("demo")), "in-page language pins present"); + assert.ok(list.innerHTML.includes("\u4e2d\u6587"), "Chinese toggle label rendered"); +}); + +test("#/blog/p
" }] }; + const r = await runClient("#/blog/plain", feed); + const list = r.els.get("bl-list")!; + assert.ok(list.innerHTML.includes("post-body"), "article still renders without a recorded thread"); + assert.ok(!list.innerHTML.includes("billion-context/discussions"), "no discussion link when the manifest recorded none"); }); test("unknown slug degrades to a back link without a crash", async () => {