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). |
| 3 | import { chromium } from 'playwright'; |
| 4 | import { fileURLToPath } from 'node:url'; |
| 5 | |
| 6 | const card = new URL('./og/card.html', import.meta.url); |
| 7 | const out = fileURLToPath(new URL('../public/og/inkspring-monochrome.png', import.meta.url)); |
| 8 | const browser = await chromium.launch(); |
| 9 | const page = await browser.newPage({ viewport: { width: 1200, height: 630 }, deviceScaleFactor: 1 }); |
| 10 | await page.goto(card.href, { waitUntil: 'networkidle' }); |
| 11 | await page.evaluate(() => document.fonts.ready); |
| 12 | await page.screenshot({ path: out, type: 'png' }); |
| 13 | await browser.close(); |
| 14 | console.log(`Wrote ${out}`); |