45 lines
1.6 KiB
JavaScript
45 lines
1.6 KiB
JavaScript
// One-off generator for the Minstrel OG / share-preview placeholder.
|
|
// Run with: cd tools && npm install && npm run gen-og-placeholder
|
|
//
|
|
// Produces ../web/static/brand/og-image.png at 1200x630, the standard
|
|
// OpenGraph aspect. The artwork is intentionally minimal — operators
|
|
// are encouraged to drop a hand-designed PNG over the same path; no
|
|
// code change is required to swap.
|
|
import sharp from 'sharp';
|
|
import { mkdir } from 'node:fs/promises';
|
|
import { resolve, dirname } from 'node:path';
|
|
import { fileURLToPath } from 'node:url';
|
|
|
|
const __dirname = dirname(fileURLToPath(import.meta.url));
|
|
const outPath = resolve(__dirname, '../web/static/brand/og-image.png');
|
|
|
|
const W = 1200;
|
|
const H = 630;
|
|
const OBSIDIAN = '#14171A';
|
|
const PARCHMENT = '#E8E4D8';
|
|
const ACCENT = '#4A6B5C';
|
|
|
|
const svg = `
|
|
<svg xmlns="http://www.w3.org/2000/svg" width="${W}" height="${H}" viewBox="0 0 ${W} ${H}">
|
|
<rect width="100%" height="100%" fill="${OBSIDIAN}"/>
|
|
<text x="50%" y="48%" text-anchor="middle"
|
|
font-family="Georgia, 'Fraunces', serif"
|
|
font-size="148" font-weight="500" fill="${PARCHMENT}"
|
|
letter-spacing="2">Minstrel</text>
|
|
<line x1="42%" y1="58%" x2="58%" y2="58%"
|
|
stroke="${ACCENT}" stroke-width="3" stroke-linecap="round"/>
|
|
<text x="50%" y="68%" text-anchor="middle"
|
|
font-family="Inter, system-ui, sans-serif"
|
|
font-size="28" fill="${PARCHMENT}" opacity="0.8">
|
|
Self-hosted music server
|
|
</text>
|
|
</svg>
|
|
`;
|
|
|
|
await mkdir(dirname(outPath), { recursive: true });
|
|
await sharp(Buffer.from(svg))
|
|
.png({ compressionLevel: 9 })
|
|
.toFile(outPath);
|
|
|
|
console.log(`wrote ${outPath}`);
|