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
import { generateFeedHTML } from "https://esm.town/v/iakovos/generateFeedHTML";
export function renderFeedsForEmail(feeds) {
let html = `
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Today's Feeds</title>
<style type="text/css">
a:hover { text-decoration: underline !important; }
img { border: 0; height: auto; line-height: 100%; outline: none; text-decoration: none; }
table { border-collapse: collapse !important; }
@media only screen and (max-width:768px) {
.article-header {
width:100% !important
}
.image-container {
height:68px !important;
width:110px !important;
}
.description {
display:none !important;
}
}
.image-container {
background-color:#E0E0E0;
border-radius:4px;
height:80px;
width:128px;
}
.image-container img {
border-radius: inherit;
display: block;
height:100%;
width:100%;
}
</style>
</head>
<body>
<div style="font-family: sans-serif; max-width:600px; margin:0 auto">
<h1 style="text-align:center; color:#333; margin-bottom: 4px;">Today's Feeds</h1>
<p style="text-align:center; font-size:1rem; color:#999;margin: 0;">${
feeds.length > 0 ? feeds[0].pubDate : "Unknown"
}</p>
`;
const blogs = feeds.filter((feed) => feed.type === "blog");
const articles = feeds.filter((feed) => feed.type !== "blog");
if (blogs.length > 0) {
html += "<h2 style=\"text-align:center; color:#333;\">Blogs</h2>";
blogs.forEach((feed) => {
html += generateFeedHTML(feed);
});
}
if (articles.length > 0) {
html += "<h2 style=\"text-align:center; color:#333;\">Articles</h2>";
articles.forEach((feed) => {
html += generateFeedHTML(feed);
});
}
html += `
</div>
</body>
</html>`;
return html;
}
Val Town is a social website to write and deploy JavaScript.
Build APIs and schedule functions from your browser.
Comments
Nobody has commented on this val yet: be the first!
October 23, 2023