Readme

Back when our blog was hosted on Notion & Super, this val would parse the blog's HTML and turn it into JSON, which would in turn be transformed into an RSS feed. Now our blog is on Astro and generates an RSS feed automatically: https://blog.val.town/rss.xml

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
import { fetchText } from "https://esm.town/v/stevekrouse/fetchText";
export async function valTownBlogJSON(): Promise<Blog[]> {
let { parse } = await import("npm:node-html-parser");
const text = await fetchText("https://blog.val.town");
return [
...parse(text)
.querySelectorAll(".notion-collection-list__item"),
].map((article) => ({
url: "https://blog.val.town" +
article
.querySelector(".notion-collection-list__item-anchor")
.getAttribute("href"),
title: article
.querySelector(".notion-semantic-string")
.querySelectorAll("span").at(-1).innerText,
date: article.querySelector(".date")?.innerText,
description: "",
}));
}
interface Blog {
url: string;
title: string;
date: string;
}
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