Readme

Send the top 5 HackerNews post to your email every day at a given Datetime.

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
import { email } from "https://esm.town/v/std/email?v=9";
export default async function(interval: Interval) {
const ntfyURL = `https://ntfy.sh/${Deno.env.get("NTFY_ID")}`;
const hnTopStoriesURL = "https://hacker-news.firebaseio.com/v0/topstories.json";
const hnStoryURL = "https://hacker-news.firebaseio.com/v0/item/";
const topStories = await fetch(hnTopStoriesURL).then((res) => res.json());
const firstFive = topStories.slice(0, 5);
const stories = await Promise.all(
firstFive.map((id: number) => fetch(`${hnStoryURL}${id}.json`).then((res) => res.json())),
);
let html;
const subject = `HackerNews Daily Resume`;
html = `<div>`;
html += "<h1>Hacker News Resume</h1>";
for (const story of stories) {
html += `<p>- <a href="${story.url}">${story.title}</a></p>`;
}
html += "</div>";
await email({
html,
subject,
});
}
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!
April 18, 2024