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
import { hnFollowCSS } from "https://esm.town/v/rodrigotello/hnFollowCSS";
import { meyerWebCSSReset } from "https://esm.town/v/rodrigotello/meyerWebCSSReset";
import { hnResultToHTML } from "https://esm.town/v/rodrigotello/hnResultToHTML";
export let hnEmail = async ({
posts,
footer,
}: {
posts: any[];
footer?: boolean; // undefined defaults to true
}) => {
let authors = Array.from(new Set(posts.map((p) => p.author))).slice(0, 3);
let subject = `[HN Follow] New from ${authors.join(", ")}`;
let postTexts = await Promise.all(
posts.map(hnResultToHTML)
);
let footer_ = [
`
<div style="background:#f1f5f9; color: #94a3b8; margin-top:40px; padding: 24px; text-align: center">
<div>Email via <a href="https://val.town/v/rodrigotello.hnFollow" style="color: #334155">HNFollowApp</a>. You can unsubscribe by clearing your intervals <a href="https://www.val.town/settings/intervals" style="color: #334155">here</a>.</div>
</div>`,
];
let html = [
`<style>${meyerWebCSSReset}; ${hnFollowCSS}</style>`,
postTexts.join("\n\n"),
...(footer === false ? [] : footer_),
].join("\n\n");
return { subject, html };
};
// Forked from @stevekrouse.hnEmail
1
Next