// Renders the raster brand assets (favicon.ico, touch icon, social card) from the SVG artwork. // Needs a local dev server for the hero scene: npm run dev, then node scripts/make-assets.mjs import { readFileSync, writeFileSync } from 'node:fs'; import { createRequire } from 'node:module'; // Playwright is expected to be installed globally (or run `npm i -D playwright` first). const { chromium } = createRequire(import.meta.url)('playwright'); const BASE = process.env.BASE_URL ?? 'http://127.0.0.1:8787'; const root = new URL('..', import.meta.url).pathname; const favicon = readFileSync(`${root}public/favicon.svg`, 'utf8'); const font = (f) => `data:font/woff2;base64,${readFileSync(`${root}public/fonts/${f}`).toString('base64')}`; const home = await (await fetch(BASE + '/')).text(); const scene = home.match(//)[0].replace('rx="28"', 'rx="0"'); const browser = await chromium.launch(); const shot = async (html, width, height, file, omitBackground = false) => { const page = await browser.newPage({ viewport: { width, height }, deviceScaleFactor: 1 }); await page.setContent(html); await page.evaluate(() => document.fonts.ready); const buf = await page.screenshot({ omitBackground }); if (file) writeFileSync(`${root}public/${file}`, buf); await page.close(); return buf; }; // The touch icon is full bleed (the OS rounds it), so it drops the corner radius and the edge line. const squareIcon = favicon.replace('rx="116"', 'rx="0"').replace(/]*\/>/, ''); const iconPage = (size, square) => `
${square ? squareIcon : favicon}
`; await shot(iconPage(180, true), 180, 180, 'img/apple-touch-icon.png'); await shot(iconPage(512, false), 512, 512, 'img/icon-512.png', true); // favicon.ico holding one 32px PNG. const png32 = await shot(iconPage(32, false), 32, 32, null, true); const head = Buffer.alloc(22); head.writeUInt16LE(0, 0); head.writeUInt16LE(1, 2); head.writeUInt16LE(1, 4); head.writeUInt8(32, 6); head.writeUInt8(32, 7); head.writeUInt8(0, 8); head.writeUInt8(0, 9); head.writeUInt16LE(1, 10); head.writeUInt16LE(32, 12); head.writeUInt32LE(png32.length, 14); head.writeUInt32LE(22, 18); writeFileSync(`${root}public/favicon.ico`, Buffer.concat([head, png32])); await shot( `
${favicon}
Skillfarm

Where agent skills grow.

A free community for sharing SKILL.md skills. Earn Seeds, climb the tiers.

${scene}
`, 1200, 630, 'img/og.png', ); await browser.close(); console.log('assets written');