import {readFileSync, writeFileSync} from 'fs' import {fileURLToPath} from 'url' import {dirname, join} from 'path' import Mustache from 'mustache' import mjml2html from 'mjml' const __dirname = dirname(fileURLToPath(import.meta.url)) const templatePath = join(__dirname, '..', 'src', 'emails', 'digest.mjml') const sample = { name: 'alice', brandName: 'Flotilla', brandAccent: '#7161FF', brandLogo: 'https://app.flotilla.social/logo.png', UserName: 'Alice', Duration: '24 hours', Total: 12, TopProfiles: 'bob, carol', HasPopular: true, Popular: [ { Link: 'https://app.flotilla.social/nevent1qqs...', Timestamp: 'Aug 25, 2026 at 9:00 AM', Icon: 'https://i.pravatar.cc/150?img=32', Name: 'carol', Content: '
Does anyone know how relay-based groups work?
', Replies: 5, Reactions: 8, }, { Link: 'https://app.flotilla.social/spaces/nos.lol/community?at=1700000000', Timestamp: 'Aug 25, 2026 at 10:00 AM', Icon: 'https://i.pravatar.cc/150?img=68', Name: 'bob', Content: 'Excited to share our new community space on Flotilla! Check it out.
', Replies: 14, Reactions: 32, }, ], unsubscribeUrl: 'https://app.flotilla.social/unsubscribe?token=abc123', } const source = readFileSync(templatePath, 'utf8') const {html} = mjml2html(Mustache.render(source, sample)) const outPath = join(__dirname, '..', 'digest-preview.html') writeFileSync(outPath, html) console.log(`Rendered preview written to ${outPath}`)