Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions AGENTS.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
```

Expand Down
1 change: 1 addition & 0 deletions docs/dev/BRANDING.md
Original file line number Diff line number Diff line change
Expand Up @@ -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`)

Expand Down
Binary file added docs/social-preview.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
73 changes: 73 additions & 0 deletions scripts/make-social-preview.mjs
Original file line number Diff line number Diff line change
@@ -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 `<!doctype html><html><head><style>
@font-face { font-family: Inter; src: url(data:font/woff2;base64,${font}) format('woff2'); font-weight: 100 900; }
* { margin: 0; box-sizing: border-box; }
body { width: ${w}px; height: ${h}px; overflow: hidden; font-family: Inter, sans-serif; color: #f2f6fb;
background: radial-gradient(120% 90% at 85% 0%, #1b4a80 0%, #102a4c 45%, #0b1a30 100%); position: relative; }
.pad { position: absolute; inset: 0; padding: ${Math.round(h * 0.11)}px ${Math.round(w * 0.075)}px; display: flex; flex-direction: column; }
.top { display: flex; align-items: center; gap: 18px; }
.logo { height: ${Math.round(h * 0.11)}px; filter: brightness(0) invert(0.96); }
.chip { font-weight: 700; font-size: ${Math.round(h * 0.034)}px; letter-spacing: .08em; text-transform: uppercase;
background: #1d5fb8; color: #fff; padding: 4px 12px; border-radius: 8px; }
.eyebrow { margin-top: auto; font-size: ${Math.round(h * 0.032)}px; font-weight: 600; letter-spacing: .14em;
text-transform: uppercase; color: #8cc4ea; }
h1 { margin-top: 14px; font-size: ${Math.round(h * 0.105)}px; line-height: 1.02; font-weight: 800;
text-transform: uppercase; letter-spacing: -.01em; max-width: 92%; }
.sub { margin-top: 18px; font-size: ${Math.round(h * 0.036)}px; color: #b9c7da; max-width: 95%; }
.url { margin-top: ${Math.round(h * 0.05)}px; font-size: ${Math.round(h * 0.034)}px; font-weight: 600; color: #f2f6fb; }
svg { position: absolute; left: 0; right: 0; bottom: 0; }
</style></head><body>
<svg width="${w}" height="${h}" viewBox="0 0 ${w} ${h}">
<path d="${wave(w, h, h * 0.83, h * 0.035)}" fill="#2a78d6" opacity=".16"/>
<path d="${wave(w, h, h * 0.89, h * 0.028)}" fill="#3987e5" opacity=".14"/>
</svg>
<div class="pad">
<div class="top"><img class="logo" src="data:image/png;base64,${logo}" alt=""><span class="chip">Data</span></div>
<p class="eyebrow">Mo'orea, French Polynesia</p>
<h1>Thirteen seasons of baby sharks, in numbers</h1>
<p class="sub">Shark-nursery surveys joined with weather, ocean, tide, climate and moon data.</p>
<p class="url">data.physioshark.org</p>
</div>
</body></html>`;
}

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();
21 changes: 18 additions & 3 deletions src/routes/+layout.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -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`
);
</script>

<svelte:head>
<title>{current && current.href !== '/' ? `${current.label} · ` : ''}Physioshark Data</title>
<title>{title}</title>
<meta name="description" content={description} />
<meta property="og:type" content="website" />
<meta property="og:site_name" content="Physioshark Data" />
<meta property="og:title" content={title} />
<meta property="og:description" content={description} />
<meta property="og:url" content={`${page.url.origin}${page.url.pathname}`} />
<meta property="og:image" content={`${page.url.origin}/og-image.png`} />
<meta property="og:image:width" content="1200" />
<meta property="og:image:height" content="630" />
<meta
name="description"
content="Thirteen seasons of Physioshark shark-nursery surveys in Mo'orea, French Polynesia, joined with weather, ocean, tide and climate data."
property="og:image:alt"
content="Physioshark Data: thirteen seasons of baby sharks, in numbers"
/>
<meta name="twitter:card" content="summary_large_image" />
</svelte:head>

<a class="skip" href="#main">Skip to content</a>
Expand Down
Binary file added static/og-image.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading