Branchwell

Inkspring / website / scripts / generate-og.mjs

1// Rebuild the 1200x630 social card from scripts/og/card.html: npm run generate:og
2// Uses Playwright's Chromium (install it with `npx playwright install chromium` if it is missing).
3import { chromium } from 'playwright';
4import { fileURLToPath } from 'node:url';
5
6const card = new URL('./og/card.html', import.meta.url);
7const out = fileURLToPath(new URL('../public/og/inkspring-monochrome.png', import.meta.url));
8const browser = await chromium.launch();
9const page = await browser.newPage({ viewport: { width: 1200, height: 630 }, deviceScaleFactor: 1 });
10await page.goto(card.href, { waitUntil: 'networkidle' });
11await page.evaluate(() => document.fonts.ready);
12await page.screenshot({ path: out, type: 'png' });
13await browser.close();
14console.log(`Wrote ${out}`);