Public
HTTP (deprecated)
Val Town is a social website to write and deploy JavaScript.
Build APIs and schedule functions from your browser.
Readme

RSS feed of stevekrouse.com essays

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
import cheerio from "npm:cheerio";
import { Feed } from "npm:feed";
export const stevekrouseRSS = async () => {
const response = await fetch("https://stevekrouse.com/");
const body = await response.text();
const $ = cheerio.load(body);
/*
<li><span class="date">2022 Nov 08 - </span><a href="https://val-town.notion.site/End-programmer-Programming-a749beb4a9b143f2990f575fb7e59b33">End-programmer Programming</a></li>
<li><span class="date">2019 Apr 17 - </span><a href="https://futureofcoding.org/notes/alan-kay-lunch">Lunch with Alan Kay: how to become educated enough to invent the future</a></li>
*/
// parse this into a JSON array with date, link, title
const parsedItems = $("#page > div:nth-child(4) > ul > li").map((_, el) => {
const date = $(el).find(".date").text().trim().replace(" -", "");
const link = $(el).find("a").attr("href");
const title = $(el).find("a").text();
return { date, link, title };
}).get();
console.log(JSON.stringify(parsedItems));
// return this as an RSS feed
const feed = new Feed({
title: "Steve Krouse's Blog",
description: "RSS Feed for Steve Krouse's Blog",
id: "https://stevekrouse.com/",
link: "https://stevekrouse.com/",
language: "en",
updated: new Date(parsedItems[0]?.date),
generator: "Cheerio & Feed for TypeScript",
});
parsedItems.forEach((item) => {
feed.addItem({
title: item.title,
id: item.link,
link: item.link,
description: item.title,
content: item.title,
date: new Date(item.date),
});
});
return new Response(feed.rss2(), {
headers: {
"Content-Type": "application/rss+xml",
},
});
};
thomasorlita-stevekrouserss.web.val.run
January 2, 2024