The buildParameters function returns events sorted newest-first (sortBy created_at, slice(0,100)), and the mjml section is already labeled 'Latest Activity'. The object keys Popular/HasPopular no longer reflect the semantics, so rename them to Latest/HasLatest.
50 lines
1.6 KiB
JavaScript
50 lines
1.6 KiB
JavaScript
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',
|
|
HasLatest: true,
|
|
Latest: [
|
|
{
|
|
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: '<p>Does anyone know how relay-based groups work?</p>',
|
|
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:
|
|
'<p>Excited to share our new community space on Flotilla! <a href="https://flotilla.social">Check it out</a>.</p>',
|
|
Replies: 14,
|
|
Reactions: 32,
|
|
},
|
|
],
|
|
unsubscribeUrl: 'https://app.flotilla.social/unsubscribe?token=abc123',
|
|
settingsUrl: 'https://app.flotilla.social/settings/alerts',
|
|
}
|
|
|
|
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}`)
|