Add Open Graph link previews to photo pages
Shared links now unfurl with an image in WhatsApp, Telegram and anything else that reads Open Graph, instead of showing the bare URL. A dedicated og/ rendition is generated per photo: 1200px longest side, quality laddered down until it fits under ~250 KB. WhatsApp drops the preview entirely once the image passes ~300 KB, and the medium rendition can exceed that, so it is not reused. Dimensions for og:image:width and og:image:height are read back from the encoded file with DecodeConfig, so they are emitted even when the rendition itself was skipped as up to date. The og:image and og:url values are absolute via BaseURL; both crawlers ignore relative image paths. Previews therefore only work against the deployed base URL, not http://localhost.
This commit is contained in:
@@ -27,7 +27,7 @@ In production nginx sits in front: serves `public/` directly, proxies `/upload`
|
||||
|
||||
- **Go** — stdlib + `BurntSushi/toml`, `fsnotify/fsnotify`, `golang.org/x/image`
|
||||
- **Templates** — `html/template`, embedded via `embed.FS`
|
||||
- **Images** — three renditions per photo: original copy, 600×600 centre-cropped square thumbnail, and a 1600px-longest-side "medium" for the detail page. Catmull-Rom resize. Outputs are skipped when newer than the source.
|
||||
- **Images** — four renditions per photo: original copy, 600×600 centre-cropped square thumbnail, a 1600px-longest-side "medium" for the detail page, and a 1200px "og" for link previews. Catmull-Rom resize. Outputs are skipped when newer than the source.
|
||||
- **Feed** — Atom (`encoding/xml`)
|
||||
- **NixOS** — `flake.nix` + `module.nix`, exports `nixosModules.default`
|
||||
|
||||
@@ -51,6 +51,19 @@ Missing sidecar → filename as caption, today as date. Photos sort newest first
|
||||
- Each timeline date heading links to a **single-day page** (`/day/<YYYY-MM-DD>/`) holding just that day's photos. `renderDayPages` writes one per `groupByDay` run; the ISO label doubles as the URL slug.
|
||||
- Single photo page with sidebar and newer/older navigation
|
||||
|
||||
### Link previews
|
||||
|
||||
Photo pages carry Open Graph + Twitter-card meta tags so a shared link unfurls
|
||||
in WhatsApp, Telegram, etc. `generateOG` writes a dedicated `public/og/`
|
||||
rendition — 1200px longest side, quality laddered down until under ~250 KB,
|
||||
because WhatsApp drops the preview above ~300 KB and the medium rendition can
|
||||
exceed that. The `og:image` URL is absolute (`{{.BaseURL}}/...`); both crawlers
|
||||
ignore relative image paths, and previews only work against the deployed
|
||||
`-base-url`, never `http://localhost`. `og:image:width`/`height` come from
|
||||
`DecodeConfig` on the OG file, read even when the file itself was skipped as up
|
||||
to date. Both platforms cache per URL — after a deploy, re-scrape via
|
||||
`@webpagebot` (Telegram) or Facebook's sharing debugger (WhatsApp).
|
||||
|
||||
### Photo page navigation
|
||||
|
||||
`static/photo-nav.js` handles arrow keys and touch swipe. Both read their
|
||||
|
||||
Reference in New Issue
Block a user