#!/usr/bin/env node // Один раз: генерирует public/og-image.png 1200x630 для расшаривания // в Telegram/VK/WhatsApp/Twitter. Требует `npm i -D sharp` (один раз). import fs from 'node:fs'; import path from 'node:path'; import { fileURLToPath } from 'node:url'; import sharp from 'sharp'; const __dirname = path.dirname(fileURLToPath(import.meta.url)); const ROOT = path.resolve(__dirname, '..'); const SVG = ` Иные Отражения Ролевой проект по современной фантастике С 2006 ГОДА `; const outPng = path.join(ROOT, 'public/og-image.png'); const outSvg = path.join(ROOT, 'public/og-image.svg'); fs.writeFileSync(outSvg, SVG.trim() + '\n', 'utf8'); console.log(`wrote ${outSvg}`); await sharp(Buffer.from(SVG)) .resize(1200, 630) .png({ compressionLevel: 9 }) .toFile(outPng); const stat = fs.statSync(outPng); console.log(`wrote ${outPng} — ${(stat.size / 1024).toFixed(1)} KB`);