Public
Script
October 23, 2023
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
import { pollRss } from "https://esm.town/v/zackoverflow/pollRss";
type UnPromise<T> = T extends Promise<infer P> ? P : T;
export const rssEntriesToHTML = async (
newRssEntries: UnPromise<ReturnType<typeof pollRss>>,
) => {
const esc = (await import("npm:escape-html")).default;
const mdStrings = [];
mdStrings.push(`<h1> RSS Update ${(new Date()).toDateString()} </h1>`);
for (const { title, url, newEntries } of newRssEntries) {
mdStrings.push(`<h2> <a href="${url}">${title}</a> </h3>`);
mdStrings.push(...newEntries.flatMap((entry) => [
`<h3> <a href="${
entry.links[0]?.href || "oops"
}">${entry.title.value}</a> </h3>`,
`<div>${entry.description.value.slice(0, 256)}...</div>`,
]));
}
return mdStrings.join("");
};
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