/* ═══════════════════════════════════════════════════════════════ EMAIL ICONS: node scripts/email-icons.mjs (from the repo root) Gmail and Outlook don't show SVG, so a newsletter's social bar (src/lib/newsletter.ts) uses PNG copies of the platform icons in PlatformIcon.tsx: white and ink, 48px square (shown at 24), into public/email/, which the build copies as they are, so the files keep their addresses in emails already sent. Run it again after adding a platform or changing an icon. Uses the server's sharp. ═══════════════════════════════════════════════════════════════ */ import { readFileSync, writeFileSync } from "node:fs"; import { createRequire } from "node:module"; const sharp = createRequire(new URL("../server/package.json", import.meta.url))("sharp"); const source = readFileSync(new URL("../src/components/PlatformIcon.tsx", import.meta.url), "utf8"); const paths = {}; for (const [, id, d] of source.matchAll(/^\s*(\w+):\s*'([^']+)'/gm)) paths[id] = d; for (const [, id, d] of source.matchAll(/^\s*(\w+):\s*\n\s*'([^']+)'/gm)) paths[id] = d; paths.instagram = /INSTAGRAM_PATH =\s*'([^']+)'/.exec(source)[1]; const TONES = { white: "#ffffff", ink: "#001011" }; for (const [id, d] of Object.entries(paths)) { for (const [tone, fill] of Object.entries(TONES)) { const svg = ``; writeFileSync(new URL(`../public/email/${id}-${tone}.png`, import.meta.url), await sharp(Buffer.from(svg)).png().toBuffer()); } } console.log(`${Object.keys(paths).length} icons: ${Object.keys(paths).join(", ")}`);