diff --git a/.gitignore b/.gitignore
index 36876ce0..618edc7e 100644
--- a/.gitignore
+++ b/.gitignore
@@ -29,5 +29,8 @@ dev-dist
.vercel
+# Ephemeral SVG with inlined font for OG PNG rasterization
+public/.og-image.raster.svg
+
.venv-i18n
scripts/i18n-overrides/.gaps
diff --git a/index.html b/index.html
index b0fe470c..95b3ded3 100644
--- a/index.html
+++ b/index.html
@@ -13,7 +13,7 @@
Imwald
diff --git a/package-lock.json b/package-lock.json
index 601ebb03..470b56c3 100644
--- a/package-lock.json
+++ b/package-lock.json
@@ -100,6 +100,7 @@
"eslint-plugin-react-refresh": "^0.4.16",
"globals": "^15.13.0",
"jsdom": "^27.1.0",
+ "opentype.js": "^1.3.4",
"postcss": "^8.4.49",
"prettier": "3.4.2",
"tailwindcss": "^3.4.17",
@@ -11888,6 +11889,23 @@
"url": "https://github.com/sponsors/sindresorhus"
}
},
+ "node_modules/opentype.js": {
+ "version": "1.3.4",
+ "resolved": "https://registry.npmjs.org/opentype.js/-/opentype.js-1.3.4.tgz",
+ "integrity": "sha512-d2JE9RP/6uagpQAVtJoF0pJJA/fgai89Cc50Yp0EJHk+eLp6QQ7gBoblsnubRULNY132I0J1QKMJ+JTbMqz4sw==",
+ "dev": true,
+ "license": "MIT",
+ "dependencies": {
+ "string.prototype.codepointat": "^0.2.1",
+ "tiny-inflate": "^1.0.3"
+ },
+ "bin": {
+ "ot": "bin/ot"
+ },
+ "engines": {
+ "node": ">= 8.0.0"
+ }
+ },
"node_modules/optionator": {
"version": "0.9.4",
"resolved": "https://registry.npmjs.org/optionator/-/optionator-0.9.4.tgz",
@@ -14046,6 +14064,13 @@
"devOptional": true,
"license": "MIT"
},
+ "node_modules/string.prototype.codepointat": {
+ "version": "0.2.1",
+ "resolved": "https://registry.npmjs.org/string.prototype.codepointat/-/string.prototype.codepointat-0.2.1.tgz",
+ "integrity": "sha512-2cBVCj6I4IOvEnjgO/hWqXjqBGsY+zwPmHl12Srk9IXSZ56Jwwmy+66XO5Iut/oQVR7t5ihYdLB0GMa4alEUcg==",
+ "dev": true,
+ "license": "MIT"
+ },
"node_modules/string.prototype.matchall": {
"version": "4.0.12",
"resolved": "https://registry.npmjs.org/string.prototype.matchall/-/string.prototype.matchall-4.0.12.tgz",
@@ -14520,6 +14545,13 @@
"semver": "bin/semver"
}
},
+ "node_modules/tiny-inflate": {
+ "version": "1.0.3",
+ "resolved": "https://registry.npmjs.org/tiny-inflate/-/tiny-inflate-1.0.3.tgz",
+ "integrity": "sha512-pkY1fj1cKHb2seWDy0B16HeWyczlJA9/WW3u3c4z/NiWDsO3DOU5D7nhTLE9CF0yXv/QZFY7sEJmj24dK+Rrqw==",
+ "dev": true,
+ "license": "MIT"
+ },
"node_modules/tinybench": {
"version": "2.9.0",
"resolved": "https://registry.npmjs.org/tinybench/-/tinybench-2.9.0.tgz",
diff --git a/package.json b/package.json
index 0afc3253..f12b595d 100644
--- a/package.json
+++ b/package.json
@@ -27,7 +27,8 @@
"i18n:translate-de": "PYTHONUNBUFFERED=1 .venv-i18n/bin/python scripts/auto_translate_i18n.py de",
"electron:dev": "concurrently -k -n vite,electron -c blue,green \"vite --host\" \"wait-on http://127.0.0.1:5173 && cross-env NODE_ENV=development electron .\"",
"build:electron": "tsc -b && vite build --base ./",
- "electron:pack": "npm run build:electron && electron-builder"
+ "electron:pack": "npm run build:electron && electron-builder",
+ "og:image": "node scripts/generate-og-png.mjs"
},
"dependencies": {
"@asciidoctor/core": "^3.0.4",
@@ -121,6 +122,7 @@
"eslint-plugin-react-refresh": "^0.4.16",
"globals": "^15.13.0",
"jsdom": "^27.1.0",
+ "opentype.js": "^1.3.4",
"postcss": "^8.4.49",
"prettier": "3.4.2",
"tailwindcss": "^3.4.17",
diff --git a/public/fonts/OFL-PlayfairDisplay.txt b/public/fonts/OFL-PlayfairDisplay.txt
new file mode 100644
index 00000000..13153890
--- /dev/null
+++ b/public/fonts/OFL-PlayfairDisplay.txt
@@ -0,0 +1,93 @@
+Copyright 2017 The Playfair Display Project Authors (https://github.com/clauseggers/Playfair-Display), with Reserved Font Name "Playfair Display"
+
+This Font Software is licensed under the SIL Open Font License, Version 1.1.
+This license is copied below, and is also available with a FAQ at:
+http://scripts.sil.org/OFL
+
+
+-----------------------------------------------------------
+SIL OPEN FONT LICENSE Version 1.1 - 26 February 2007
+-----------------------------------------------------------
+
+PREAMBLE
+The goals of the Open Font License (OFL) are to stimulate worldwide
+development of collaborative font projects, to support the font creation
+efforts of academic and linguistic communities, and to provide a free and
+open framework in which fonts may be shared and improved in partnership
+with others.
+
+The OFL allows the licensed fonts to be used, studied, modified and
+redistributed freely as long as they are not sold by themselves. The
+fonts, including any derivative works, can be bundled, embedded,
+redistributed and/or sold with any software provided that any reserved
+names are not used by derivative works. The fonts and derivatives,
+however, cannot be released under any other type of license. The
+requirement for fonts to remain under this license does not apply
+to any document created using the fonts or their derivatives.
+
+DEFINITIONS
+"Font Software" refers to the set of files released by the Copyright
+Holder(s) under this license and clearly marked as such. This may
+include source files, build scripts and documentation.
+
+"Reserved Font Name" refers to any names specified as such after the
+copyright statement(s).
+
+"Original Version" refers to the collection of Font Software components as
+distributed by the Copyright Holder(s).
+
+"Modified Version" refers to any derivative made by adding to, deleting,
+or substituting -- in part or in whole -- any of the components of the
+Original Version, by changing formats or by porting the Font Software to a
+new environment.
+
+"Author" refers to any designer, engineer, programmer, technical
+writer or other person who contributed to the Font Software.
+
+PERMISSION & CONDITIONS
+Permission is hereby granted, free of charge, to any person obtaining
+a copy of the Font Software, to use, study, copy, merge, embed, modify,
+redistribute, and sell modified and unmodified copies of the Font
+Software, subject to the following conditions:
+
+1) Neither the Font Software nor any of its individual components,
+in Original or Modified Versions, may be sold by itself.
+
+2) Original or Modified Versions of the Font Software may be bundled,
+redistributed and/or sold with any software, provided that each copy
+contains the above copyright notice and this license. These can be
+included either as stand-alone text files, human-readable headers or
+in the appropriate machine-readable metadata fields within text or
+binary files as long as those fields can be easily viewed by the user.
+
+3) No Modified Version of the Font Software may use the Reserved Font
+Name(s) unless explicit written permission is granted by the corresponding
+Copyright Holder. This restriction only applies to the primary font name as
+presented to the users.
+
+4) The name(s) of the Copyright Holder(s) or the Author(s) of the Font
+Software shall not be used to promote, endorse or advertise any
+Modified Version, except to acknowledge the contribution(s) of the
+Copyright Holder(s) and the Author(s) or with their explicit written
+permission.
+
+5) The Font Software, modified or unmodified, in part or in whole,
+must be distributed entirely under this license, and must not be
+distributed under any other license. The requirement for fonts to
+remain under this license does not apply to any document created
+using the Font Software.
+
+TERMINATION
+This license becomes null and void if any of the above conditions are
+not met.
+
+DISCLAIMER
+THE FONT SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO ANY WARRANTIES OF
+MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT
+OF COPYRIGHT, PATENT, TRADEMARK, OR OTHER RIGHT. IN NO EVENT SHALL THE
+COPYRIGHT HOLDER BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+INCLUDING ANY GENERAL, SPECIAL, INDIRECT, INCIDENTAL, OR CONSEQUENTIAL
+DAMAGES, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+FROM, OUT OF THE USE OR INABILITY TO USE THE FONT SOFTWARE OR FROM
+OTHER DEALINGS IN THE FONT SOFTWARE.
diff --git a/public/fonts/PlayfairDisplay-wght.ttf b/public/fonts/PlayfairDisplay-wght.ttf
new file mode 100644
index 00000000..7a09eb71
Binary files /dev/null and b/public/fonts/PlayfairDisplay-wght.ttf differ
diff --git a/public/og-image.png b/public/og-image.png
index 93bff78b..8650f23d 100644
Binary files a/public/og-image.png and b/public/og-image.png differ
diff --git a/public/og-image.svg b/public/og-image.svg
new file mode 100644
index 00000000..817e84af
--- /dev/null
+++ b/public/og-image.svg
@@ -0,0 +1,37 @@
+
diff --git a/scripts/generate-og-png.mjs b/scripts/generate-og-png.mjs
new file mode 100644
index 00000000..3a408cde
--- /dev/null
+++ b/scripts/generate-og-png.mjs
@@ -0,0 +1,68 @@
+/**
+ * Rasterize public/og-image.svg → public/og-image.png with a true Playfair Display wordmark.
+ * ImageMagick/Inkscape copy the SVG to /tmp, so @font-face + file URLs often never load;
+ * we outline "Imwald" with opentype.js so the PNG is font-independent.
+ *
+ * Wordmark fill + weight are read from the `#og-imwald` in the SVG so PNG matches
+ * the green-tinged off-white you see in the browser (rasterizers often look harsher than live text).
+ */
+import { execFileSync } from 'node:child_process'
+import { readFileSync, writeFileSync, unlinkSync } from 'node:fs'
+import { dirname, join } from 'node:path'
+import { fileURLToPath } from 'node:url'
+import opentype from 'opentype.js'
+
+const root = join(dirname(fileURLToPath(import.meta.url)), '..')
+const svgPath = join(root, 'public/og-image.svg')
+const fontPath = join(root, 'public/fonts/PlayfairDisplay-wght.ttf')
+const outPng = join(root, 'public/og-image.png')
+const tmpSvg = join(root, 'public/.og-image.raster.svg')
+
+function parseOgImwaldFromSvg(svg) {
+ const defaults = { fill: '#d4ebe0', weight: 700, letterSpacing: 0.018 }
+ const idPos = svg.indexOf('id="og-imwald"')
+ if (idPos < 0) return defaults
+ const textOpen = svg.lastIndexOf('', idPos)
+ if (textOpen < 0 || textClose < 0) return defaults
+ const t = svg.slice(textOpen, textClose + ''.length)
+ const fill = t.match(/\bfill="([^"]+)"/)?.[1] ?? defaults.fill
+ const weight = parseInt(t.match(/font-weight="(\d+)"/)?.[1] ?? String(defaults.weight), 10)
+ return {
+ fill,
+ weight: Number.isFinite(weight) ? weight : defaults.weight,
+ letterSpacing: defaults.letterSpacing
+ }
+}
+
+let svg = readFileSync(svgPath, 'utf8')
+const { fill: imwaldFill, weight: imwaldWght, letterSpacing } = parseOgImwaldFromSvg(svg)
+
+const font = opentype.loadSync(fontPath)
+const pathObj = font.getPath('Imwald', 72, 300, 108, {
+ variation: { wght: imwaldWght },
+ letterSpacing
+})
+let pathTag = pathObj.toSVG(2)
+if (!pathTag.includes('fill=')) {
+ pathTag = pathTag.replace(']*id="og-imwald"[^>]*>[\s\S]*?<\/text>/, pathTag)
+
+writeFileSync(tmpSvg, svg, 'utf8')
+
+try {
+ execFileSync('convert', ['-background', 'none', '-density', '150', tmpSvg, outPng], {
+ stdio: 'inherit',
+ cwd: root
+ })
+} finally {
+ try {
+ unlinkSync(tmpSvg)
+ } catch {
+ /* ignore */
+ }
+}
+
+console.info('[og:image] wrote', outPng)
diff --git a/src/PageManager.tsx b/src/PageManager.tsx
index 41e66359..8b81042f 100644
--- a/src/PageManager.tsx
+++ b/src/PageManager.tsx
@@ -41,6 +41,11 @@ import {
usePrimaryPageOptional,
type PrimaryPageContextValue
} from '@/contexts/primary-page-context'
+import {
+ applyRouteDocumentMeta,
+ isNoteDetailPathname,
+ isProfileDetailPathname
+} from '@/lib/document-meta'
import { normalizeUrl } from './lib/url'
import modalManager from './services/modal-manager.service'
import { decodeRssArticlePathSegment, encodeRssArticlePathSegment } from '@/lib/rss-article'
@@ -1761,6 +1766,25 @@ export function PageManager({ maxStackSize = 5 }: { maxStackSize?: number }) {
}
}, [secondaryStack.length, currentPrimaryPage])
+ // Route-level OG / document title for pages that do not set their own (NotePage, ProfilePage handle note/profile).
+ useEffect(() => {
+ if (typeof window === 'undefined') return
+ if (primaryNoteView !== null) return
+
+ const top = secondaryStack[secondaryStack.length - 1]
+ let path = window.location.pathname
+ if (top?.url) {
+ try {
+ path = new URL(top.url, window.location.origin).pathname
+ } catch {
+ /* keep window pathname */
+ }
+ }
+
+ if (isNoteDetailPathname(path) || isProfileDetailPathname(path)) return
+
+ applyRouteDocumentMeta(path, currentPrimaryPage)
+ }, [secondaryStack, currentPrimaryPage, primaryNoteView])
const navigatePrimaryPage = (page: TPrimaryPageName, props?: any) => {
// Clear any primary note view when navigating to a new primary page
diff --git a/src/components/WebPreview/index.tsx b/src/components/WebPreview/index.tsx
index 2ac9327a..3691ae6f 100644
--- a/src/components/WebPreview/index.tsx
+++ b/src/components/WebPreview/index.tsx
@@ -13,6 +13,7 @@ import { nip19, kinds } from 'nostr-tools'
import { useMemo, useEffect, useState } from 'react'
import Image from '../Image'
import Username from '../Username'
+import { resolveImwaldRouteSocialCopy } from '@/lib/document-meta'
import { cleanUrl, isSafeMediaUrl } from '@/lib/url'
import { tagNameEquals } from '@/lib/tag'
import { queryService } from '@/services/client.service'
@@ -519,11 +520,14 @@ export default function WebPreview({ url, className }: { url: string; className?
// Render all images on left side, crop wider ones
return (