-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.js
135 lines (126 loc) · 4.4 KB
/
index.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
import { createSSRApp } from 'vue'
import { renderToString } from 'vue/server-renderer'
import mjml2html from 'mjml'
import fs from 'fs'
async function renderEmail(type, data, customUtms = {}) {
const template = fs.readFileSync(`./templates/${type}.mjml`, 'utf8')
const defaultUtms = {
campaign: type,
medium: 'email',
source: 'newsletter',
}
const utm = {
...defaultUtms,
...customUtms,
}
const app = createSSRApp({
data: () => {
return data
},
template,
methods: {
link(url, utmContent = '') {
return (
url +
'?utm_campaign=' +
utm.campaign +
'&utm_medium=' +
utm.medium +
'&utm_source=' +
utm.source +
'&utm_content=' +
utmContent
)
},
},
})
app.config.compilerOptions.isCustomElement = (tag) => tag.startsWith('mj')
return mjml2html(await renderToString(app)).html
}
async function getWeeklyData(city) {
const data = {
intro:
'Hope you had a great weekend and are ready with your dancing shoes on for a fantastic week ahead.',
title: 'Munich Dance Calendar',
links: {
telegram: 'https://t.me/WeDanceMunich',
instagram: 'https://instagram.com/WeDanceMunich',
facebook: 'https://fb.com/WeDanceMunich',
addEvent: 'https://wedance.vip/events/-/edit',
city: 'https://wedance.vip/Munich',
},
days: [
{
day: 'Monday',
date: '11 Nov',
events: [
{
title: 'Kizomba Party',
organizer: 'circulo',
venue: 'Circulo Tanzschule',
format: 'Party',
time: '21:30',
link: 'https://wedance.vip/events/C7YH4kKw5xz9QEARnSxI',
cover:
'https://firebasestorage.googleapis.com/v0/b/wedance-4abe3.appspot.com/o/media%2FtvR012ArEpQhCJdPHh6G7sLuqoO2%2Fc4439150-5e5c-4bbb-9f96-1ac1910f80bf?alt=media&token=64366542-00c1-43b8-a3cb-5f72f47a7f4c',
styles: ['Bachata', 'Kizomba'],
},
{
title: 'Bachata Party',
organizer: 'circulo',
venue: 'Circulo Tanzschule',
format: 'Party',
time: '21:30',
link: 'https://wedance.vip/events/C7YH4kKw5xz9QEARnSxI',
cover:
'https://firebasestorage.googleapis.com/v0/b/wedance-4abe3.appspot.com/o/media%2FtvR012ArEpQhCJdPHh6G7sLuqoO2%2Fc4439150-5e5c-4bbb-9f96-1ac1910f80bf?alt=media&token=64366542-00c1-43b8-a3cb-5f72f47a7f4c',
styles: ['Bachata', 'Kizomba'],
},
],
},
{
day: 'Tuesday',
date: '12 Nov',
events: [
{
title: 'Kizomba Party',
organizer: 'circulo',
venue: 'Circulo Tanzschule',
format: 'Party',
time: '21:30',
link: 'https://wedance.vip/events/C7YH4kKw5xz9QEARnSxI',
cover:
'https://firebasestorage.googleapis.com/v0/b/wedance-4abe3.appspot.com/o/media%2FtvR012ArEpQhCJdPHh6G7sLuqoO2%2Fc4439150-5e5c-4bbb-9f96-1ac1910f80bf?alt=media&token=64366542-00c1-43b8-a3cb-5f72f47a7f4c',
styles: ['Bachata', 'Kizomba'],
},
{
title: 'Bachata Party',
organizer: 'circulo',
venue: 'Circulo Tanzschule',
format: 'Party',
time: '21:30',
link: 'https://wedance.vip/events/C7YH4kKw5xz9QEARnSxI',
cover:
'https://firebasestorage.googleapis.com/v0/b/wedance-4abe3.appspot.com/o/media%2FtvR012ArEpQhCJdPHh6G7sLuqoO2%2Fc4439150-5e5c-4bbb-9f96-1ac1910f80bf?alt=media&token=64366542-00c1-43b8-a3cb-5f72f47a7f4c',
styles: ['Bachata', 'Kizomba'],
},
{
title: 'Salsa Party',
organizer: 'circulo',
venue: 'Circulo Tanzschule',
format: 'Party',
time: '21:30',
link: 'https://wedance.vip/events/C7YH4kKw5xz9QEARnSxI',
cover:
'https://firebasestorage.googleapis.com/v0/b/wedance-4abe3.appspot.com/o/media%2FtvR012ArEpQhCJdPHh6G7sLuqoO2%2Fc4439150-5e5c-4bbb-9f96-1ac1910f80bf?alt=media&token=64366542-00c1-43b8-a3cb-5f72f47a7f4c',
styles: ['Bachata', 'Kizomba'],
},
],
},
],
}
return data
}
const data = await getWeeklyData('Munich')
const html = await renderEmail('weekly', data)
fs.writeFileSync('./emails/weekly.html', html)