/** * Render public/og.png from the site's own design tokens and webfont. * * Rendered in a browser rather than drawn by hand so the share card cannot * drift away from the page it advertises: same Be Vietnam Pro, same navy, * same seal vermilion, same rules. Re-run after changing the palette. * * node scripts/make-og.mjs */ import { chromium } from "@playwright/test"; import { fileURLToPath } from "node:url"; import { dirname, resolve } from "node:path"; const here = dirname(fileURLToPath(import.meta.url)); const out = resolve(here, "../public/og.png"); const fontsDir = resolve(here, "../node_modules/@fontsource/be-vietnam-pro/files"); const html = `
CarePath

Người bệnh nước ngoài rời phòng khám với tờ giấy họ không đọc được.

CarePath dịch cả buổi khám và cả giấy tờ, rồi giữ lại phần nguy hiểm cho tới khi bác sĩ xác nhận.

Phòng khám đa khoaĐƠN THUỐC
Amoxicillin 500 mg — Uống 1 viên, ngày 2 lần
Chờ bác sĩ xác nhận
Không uống rượu trong thời gian dùng thuốc
Do not drink alcohol while taking this medicine
Tái khám sau 5 ngày
Return for review after 5 days
`; const browser = await chromium.launch(); const page = await browser.newPage({ viewport: { width: 1200, height: 630 } }); await page.setContent(html, { waitUntil: "networkidle" }); // Runs in the page, not in node — hence the string form. await page.evaluate("document.fonts.ready"); await page.screenshot({ path: out }); await browser.close(); console.log(`wrote ${out}`);