From f3a3d88c7d5a86ae1fa06cf23932631eaa050151 Mon Sep 17 00:00:00 2001 From: Adam Soltys Date: Thu, 22 Oct 2026 08:42:47 -0700 Subject: Links to coinos unfurl with a share card: site-wide Open Graph/Twitter tags and a 1200×630 og-image.png. Note and profile pages swap the site's tags for their own and fall back to the card when they have no picture. README links coinosv3-server on gittr. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-Authored-By: Claude Opus 5.5 --- feed/note-page.js | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) (limited to 'feed/note-page.js') diff --git a/feed/note-page.js b/feed/note-page.js index 3145f14..89b2f43 100644 --- a/feed/note-page.js +++ b/feed/note-page.js @@ -126,6 +126,12 @@ function nameOf(data, pk) { try { const m = JSON.parse(p.content); return { name: m.display_name || m.name || null, picture: m.picture || null }; } catch { return {}; } } +// index.html carries the site's own share tags between these markers; a +// rendered page drops them for its own (crawlers take the first of a pair). +// The site's picture stays as the stand-in for a page that has none. +export const siteTagsOut = (html) => html.replace(/[\s\S]*?\n?/, ''); +export const siteImage = (origin) => (origin ? origin + '/og-image.png' : ''); + // The app's index.html with the thread and its preview tags in the head. export function renderNotePage(html, data, ref, origin) { const focus = [data.root, ...data.replies].find((e) => e.id === ref.id) || data.root; @@ -141,13 +147,13 @@ export function renderNotePage(html, data, ref, origin) { desc ? `` : '', desc ? `` : '', origin ? `` : '', - image ? `` : '', - ``, + image || siteImage(origin) ? `` : '', + ``, // the author's face starts downloading with the page, not after the app boots who.picture && /^https:\/\//.test(who.picture) ? `` : '', ``, ].filter(Boolean).join('\n'); - let out = html.replace(/[^<]*<\/title>/i, `<title>${esc(title)}`); + let out = siteTagsOut(html).replace(/[^<]*<\/title>/i, `<title>${esc(title)}`); out = out.includes('') ? out.replace('', head + '\n') : head + out; return out; } -- cgit v1.2.3