Something went wrong. Try again.
Browser extension: detect and subscribe to standard.site publications on ATProto substandard.blog
Something went wrong. Try again.
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566// Drawing constants and helpers shared by panoptiblog's social cards. Both// the site-wide card and the per-publication cards go through resvg with the// same palette, fonts and brand mark.
import { readFileSync } from 'node:fs'
import { Resvg } from '@resvg/resvg-js'
export const CARD_WIDTH = 1200export const CARD_HEIGHT = 630
export const INK = '#26282b'export const MUTED = '#6d6a62'export const RED = '#d9482b'export const GOLD = '#e8b52a'export const PAPER = '#f4f3ee'export const CARD = '#fdfcf9'export const LINE = '#dedcd3'
export const SANS = 'DejaVu Sans'export const MONO = 'DejaVu Sans Mono'
const MARK = readFileSync(new URL('./og-mark.svg', import.meta.url), 'utf8')
export function esc(value) { return String(value ?? '') .replaceAll('&', '&') .replaceAll('<', '<') .replaceAll('>', '>') .replaceAll('"', '"')}
/** A run's `generatedAt` as a UTC day, such as "21 Nov 2026"; '' when unusable. */export function runDate(value) { if (!value) return '' const date = new Date(value) if (Number.isNaN(date.getTime())) return '' return date.toLocaleDateString('en-GB', { day: 'numeric', month: 'short', year: 'numeric', timeZone: 'UTC', })}
export function clip(value, max) { const text = String(value ?? '').trim() return text.length > max ? `${text.slice(0, max - 1).trimEnd()}…` : text}
export function mark(width, x, y) { return MARK.replace('<?xml', '<!--').replace( '<svg ', `<svg x="${x}" y="${y}" width="${width}" height="${width}" `, )}
/** Rasterize one SVG composition; returns a PNG buffer. */export function renderSvg(svg) { return new Resvg(svg, { font: { loadSystemFonts: true, defaultFontFamily: SANS }, }) .render() .asPng()}