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
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