// With Chrome and Playwright installed, run: node tools/render-social-card.js // Copy the reviewed social-card.png from Expand into the site when publishing it. const fs = require('node:fs'); const path = require('node:path'); const { pathToFileURL } = require('node:url'); const { chromium } = require('playwright'); const expand = '/Volumes/Expand'; const output = path.join(expand, 'Codex Media', 'Voxley', 'Website Art'); async function renderSocialCard() { if (!fs.existsSync(expand) || fs.statSync(expand).dev === fs.statSync(path.dirname(expand)).dev) { throw new Error('Mount Expand before rendering the Voxley social card.'); } const temporary = path.join(output, 'tmp'); fs.mkdirSync(temporary, { recursive: true }); process.env.TMPDIR = temporary; const browser = await chromium.launch({ channel: 'chrome' }); try { const page = await browser.newPage({ viewport: { width: 1200, height: 630 }, deviceScaleFactor: 1 }); await page.goto(pathToFileURL(path.join(__dirname, 'social-card.html')).href); await page.evaluate(() => document.fonts.ready); const card = path.join(output, 'social-card.png'); await page.screenshot({ path: card }); console.log(card); } finally { await browser.close(); } } renderSocialCard().catch(error => { console.error(error.message); process.exitCode = 1; });