diff --git a/AGENTS.md b/AGENTS.md index 4dfc1df..0694509 100644 --- a/AGENTS.md +++ b/AGENTS.md @@ -98,6 +98,7 @@ pnpm build && pnpm test:e2e # Playwright + axe against the production build pnpm db:generate # after editing schema.ts pnpm external # refresh environmental snapshots pnpm fixture # regenerate synthetic workbooks +pnpm social-preview # re-render static/og-image.png + docs/social-preview.png (Playwright) REAL_DATA_DIR=data pnpm vitest run src/lib/server/import/realData.test.ts # opt-in real-data summary ``` diff --git a/docs/dev/BRANDING.md b/docs/dev/BRANDING.md index 8efcf21..cb5227c 100644 --- a/docs/dev/BRANDING.md +++ b/docs/dev/BRANDING.md @@ -8,6 +8,7 @@ Matches [physioshark.org](https://physioshark.org/): clean, corporate, ocean-blu - Page titles 700, section titles 650, body 400 at 16 px / 1.6. Hero headline uppercase like the main site. - Logo: the Physioshark project logo (`static/logo-physioshark.png`, from [RummerLab/physioshark-project](https://github.com/RummerLab/physioshark-project)) followed by a `DATA` chip (white on `#1d5fb8` in both themes for contrast). On dark surfaces it is shown as a light monochrome (`filter`), since the navy half would vanish. - Icon: `static/favicon.svg` is the project's shark mark (with a lighter navy under `prefers-color-scheme: dark`). `PhysiosharkIcon.svelte` inlines it with `--mark-light` / `--mark-dark` colours for the navy footer. Don't redraw or recolour the mark beyond that. +- Social preview: `scripts/make-social-preview.mjs` renders `static/og-image.png` (1200×630, `og:image`) and `docs/social-preview.png` (1280×640, uploaded by hand under the GitHub repo's Settings → Social preview). The wave is decorative, not data, so the images don't go stale. ## Colour tokens (`src/app.css`) diff --git a/docs/social-preview.png b/docs/social-preview.png new file mode 100644 index 0000000..2095c98 Binary files /dev/null and b/docs/social-preview.png differ diff --git a/package.json b/package.json index 212b18b..d1650d3 100644 --- a/package.json +++ b/package.json @@ -22,6 +22,7 @@ "format": "prettier --write --cache --cache-strategy content .", "db:generate": "drizzle-kit generate", "fixture": "node scripts/make-fixture.mjs", + "social-preview": "node scripts/make-social-preview.mjs", "external": "node scripts/fetch-external.mjs", "import": "node scripts/import.mjs", "start": "node scripts/server.mjs" diff --git a/scripts/make-social-preview.mjs b/scripts/make-social-preview.mjs new file mode 100644 index 0000000..40d01fc --- /dev/null +++ b/scripts/make-social-preview.mjs @@ -0,0 +1,73 @@ +/** + * Renders the social preview images (#30) with Playwright's Chromium: + * static/og-image.png 1200×630 og:image / twitter:image for data.physioshark.org + * docs/social-preview.png 1280×640 GitHub repository social preview (upload by hand) + * + * The wave is a stylised two-tide day, not data, so the images never go stale. + * Run: pnpm social-preview + */ +import { chromium } from '@playwright/test'; +import { readFileSync } from 'node:fs'; +import { resolve } from 'node:path'; + +const root = resolve(import.meta.dirname, '..'); +const b64 = (p) => readFileSync(resolve(root, p)).toString('base64'); +const font = b64('node_modules/@fontsource-variable/inter/files/inter-latin-wght-normal.woff2'); +const logo = b64('static/logo-physioshark.png'); + +/** Sea level over a day at Mo'orea: two highs (noon, midnight), small and regular. */ +function wave(width, height, base, amp) { + const pts = []; + for (let x = 0; x <= width; x += 8) { + const t = (x / width) * 2 * Math.PI * 1.5; + pts.push(`${x},${(base - amp * Math.cos(2 * t) - amp * 0.25 * Math.cos(t + 0.6)).toFixed(1)}`); + } + return `M0,${height} L${pts.join(' L')} L${width},${height} Z`; +} + +function html(w, h) { + return ` + + + + +
+
Data
+

Mo'orea, French Polynesia

+

Thirteen seasons of baby sharks, in numbers

+

Shark-nursery surveys joined with weather, ocean, tide, climate and moon data.

+

data.physioshark.org

+
+`; +} + +const browser = await chromium.launch(); +for (const [file, w, h] of [ + ['static/og-image.png', 1200, 630], + ['docs/social-preview.png', 1280, 640] +]) { + const page = await browser.newPage({ viewport: { width: w, height: h } }); + await page.setContent(html(w, h), { waitUntil: 'load' }); + await page.evaluate(() => document.fonts.ready); + await page.screenshot({ path: resolve(root, file) }); + await page.close(); + console.log(`wrote ${file}`); +} +await browser.close(); diff --git a/src/routes/+layout.svelte b/src/routes/+layout.svelte index 8bdf842..51c7a1b 100644 --- a/src/routes/+layout.svelte +++ b/src/routes/+layout.svelte @@ -48,15 +48,30 @@ const active = (href: string) => href === '/' ? page.url.pathname === '/' : page.url.pathname.startsWith(href); const version = __APP_VERSION__; + const description = + "Thirteen seasons of Physioshark shark-nursery surveys in Mo'orea, French Polynesia, joined with weather, ocean, tide and climate data."; const current = $derived(NAV.flatMap((g) => g.items).find((i) => active(i.href))); + const title = $derived( + `${current && current.href !== '/' ? `${current.label} · ` : ''}Physioshark Data` + ); - {current && current.href !== '/' ? `${current.label} · ` : ''}Physioshark Data + {title} + + + + + + + + + + diff --git a/static/og-image.png b/static/og-image.png new file mode 100644 index 0000000..9156692 Binary files /dev/null and b/static/og-image.png differ