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 --- README.md | 3 ++- build.js | 24 ++++++++++++++++++++++-- feed/note-page.js | 12 +++++++++--- feed/profile-page.js | 8 ++++---- static/og-image.png | Bin 0 -> 122763 bytes 5 files changed, 37 insertions(+), 10 deletions(-) create mode 100644 static/og-image.png diff --git a/README.md b/README.md index 4227479..077b71a 100644 --- a/README.md +++ b/README.md @@ -225,7 +225,8 @@ bun run build # → dist/ The app is static. The small services that run beside it (Bun) live in their own repository, **[coinosv3-server](https://github.com/coinos/coinosv3-server)** -(also at https://git.coinos.io/coinosv3-server.git): the payment-name +(also at https://git.coinos.io/coinosv3-server.git and on Nostr via +[gittr](https://gittr.space/npub1w27mc4aa6m0ufe3xs5z3m6qyr52gc0rglept7vqlwx4xeaf72tasnqz70r/coinosv3-server)): the payment-name registrar (`names.coinos.io`: BIP-353 records, LNURL-pay for `@coinos.io` names, link previews, translation), the NWC push notifier (`nwcpush`), the Blossom server for encrypted sync envelopes (`blossom.coinos.io`), the diff --git a/build.js b/build.js index 5a279c4..eb81f80 100644 --- a/build.js +++ b/build.js @@ -14,7 +14,7 @@ import { mkdir, readdir } from 'node:fs/promises'; const FAVICON = 'data:image/svg+xml,%3Csvg%20width%3D%2272%22%20height%3D%2272%22%20viewBox%3D%220%200%2072%2072%22%20fill%3D%22none%22%20xmlns%3D%22http%3A//www.w3.org/2000/svg%22%3E%20%3Cpath%20d%3D%22M69.8824%2036C69.8824%2054.7127%2054.7127%2069.8824%2036%2069.8824C17.2873%2069.8824%202.11765%2054.7127%202.11765%2036C2.11765%2017.2873%2017.2873%202.11765%2036%202.11765C54.7127%202.11765%2069.8824%2017.2873%2069.8824%2036Z%22%20fill%3D%22white%22/%3E%20%3Cpath%20fill-rule%3D%22evenodd%22%20clip-rule%3D%22evenodd%22%20d%3D%22M36%204.23529C18.4568%204.23529%204.23529%2018.4568%204.23529%2036C4.23529%2053.5432%2018.4568%2067.7647%2036%2067.7647C53.5432%2067.7647%2067.7647%2053.5432%2067.7647%2036C67.7647%2018.4568%2053.5432%204.23529%2036%204.23529ZM0%2036C0%2016.1177%2016.1177%200%2036%200C55.8823%200%2072%2016.1177%2072%2036C72%2055.8823%2055.8823%2072%2036%2072C16.1177%2072%200%2055.8823%200%2036Z%22%20fill%3D%22black%22/%3E%20%3Cpath%20fill-rule%3D%22evenodd%22%20clip-rule%3D%22evenodd%22%20d%3D%22M36%2058.5882C48.4751%2058.5882%2058.5882%2048.4751%2058.5882%2036C58.5882%2023.5248%2048.4751%2013.4117%2036%2013.4117C23.5249%2013.4117%2013.4118%2023.5248%2013.4118%2036C13.4118%2048.4751%2023.5249%2058.5882%2036%2058.5882ZM36%2054C45.9411%2054%2054%2045.9411%2054%2036C54%2026.0589%2045.9411%2018%2036%2018C26.0589%2018%2018%2026.0589%2018%2036C18%2045.9411%2026.0589%2054%2036%2054Z%22%20fill%3D%22black%22/%3E%20%3Cpath%20fill-rule%3D%22evenodd%22%20clip-rule%3D%22evenodd%22%20d%3D%22M36.0001%2022.8988C36.0001%2022.8988%2036%2022.8988%2036%2022.8988C28.7644%2022.8988%2022.8988%2028.7644%2022.8988%2036C22.8988%2043.2356%2028.7644%2049.1012%2036%2049.1012C36%2049.1012%2036.0001%2049.1012%2036.0001%2049.1012V22.8988Z%22%20fill%3D%22black%22/%3E%20%3C/svg%3E'; // Static assets copied verbatim into dist/ (icons referenced by the manifest). -const STATIC = ['icon-192.png', 'icon-512.png', 'icon-maskable-512.png', 'icon.svg', 'badge-96.png', 'PublicSans.woff2', 'PublicSans-Italic.woff2', 'PublicSans-OFL.txt']; +const STATIC = ['icon-192.png', 'icon-512.png', 'icon-maskable-512.png', 'icon.svg', 'badge-96.png', 'og-image.png', 'PublicSans.woff2', 'PublicSans-Italic.woff2', 'PublicSans-OFL.txt']; const MANIFEST = { id: '/', @@ -394,6 +394,26 @@ const BOOT_SHELL_SCRIPT = ` +${siteTags(staging)}${pwa ? PWA_HEAD : ''} 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; } diff --git a/feed/profile-page.js b/feed/profile-page.js index a30c2ab..623dc09 100644 --- a/feed/profile-page.js +++ b/feed/profile-page.js @@ -11,7 +11,7 @@ // page goes out (and the build carries on into the cache). import { decode } from 'nostr-tools/nip19'; import { verifyEvent } from 'nostr-tools/pure'; -import { NOTE_RELAYS, esc, scriptJson } from './note-page.js'; +import { NOTE_RELAYS, esc, scriptJson, siteTagsOut, siteImage } from './note-page.js'; export const PROFILE_PATH = /^\/((?:npub1|nprofile1)[a-z0-9]+|[A-Za-z0-9._-]{1,30})\/?$/; // single-segment app routes and files that are never a person @@ -186,14 +186,14 @@ export function renderProfilePage(html, data, ref, origin) { desc ? `` : '', desc ? `` : '', origin ? `` : '', - picture ? `` : '', - ``, + picture || siteImage(origin) ? `` : '', + ``, // the face and the cover start downloading with the page picture ? `` : '', banner ? `` : '', ``, ].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; } diff --git a/static/og-image.png b/static/og-image.png new file mode 100644 index 0000000..c048083 Binary files /dev/null and b/static/og-image.png differ -- cgit v1.2.3