Subscribe to RSS feeds with e-mail notifications

This lets you subscribe to RSS feeds. It checks periodically for any new posts from any of your RSS feed subscriptions, and then sends you an e-mail with the link to the any new posts.

Getting started

1. Generate auth keys

Follow this to get your auth keys, and export your public keys. This will be used to e-mail yourself since @std.email is preferred over console.email

2. Create a @me.rssEmail val

You can do that by clicking this link and hitting 'Run'.

Or you can copy-paste this code into a new val:

const rssEmail = "you@youremail.com"

3. Fork this val

Hit 'Fork' on this val and run it. Then you can schedule the val to run every hour or whatever duration you'd like.

4. Add RSS feeds to @me.rssFeeds

If you look at your vals, you should find a new one called rssFeeds. It should look similar to this:

let rssFeeds = [
  "https://cprimozic.net/rss.xml",
  "https://matklad.github.io/feed.xml",
  "https://journal.stuffwithstuff.com/rss.xml",
  "https://lexi-lambda.github.io/feeds/all.rss.xml",
];

This is supposed to be an array containing the links of each RSS feed you'd like to subscribe to (in the form of JS strings).

To add RSS feeds, you can update this val by adding a new string containing the new RSS link.

Resetting the cache

If for any reason you would like to reset the cache, you can clear the keys of rssCache or use this convenience function to do so.

@zackoverflow.rssResetCache(@me.rssCache)
Readme
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
import { email } from "https://esm.town/v/std/email?v=9";
import { rssEntriesToHTML } from "https://esm.town/v/zackoverflow/rssEntriesToHTML";
import { set } from "https://esm.town/v/std/set?v=11";
import { pollRss } from "https://esm.town/v/zackoverflow/pollRss";
import { rssEmail } from "https://esm.town/v/zackoverflow/rssEmail";
let { rssCache } = await import("https://esm.town/v/zackoverflow/rssCache");
let { rssFeeds } = await import("https://esm.town/v/zackoverflow/rssFeeds");
export const pollRssAndEmail = async () => {
rssFeeds = rssFeeds ??
["https://journal.stuffwithstuff.com/rss.xml"];
rssCache = rssCache ?? {} as any;
if (typeof rssEmail !== "string")
throw new Error(
"You haven't set your email, please create a val called @rssEmail and set its value to your e-mail address.",
);
const rssEntries = await pollRss(
rssFeeds,
rssCache,
);
await set("rssCache", rssCache);
if (rssEntries.length === 0)
return;
const html = await rssEntriesToHTML(rssEntries);
return await email({
to: [rssEmail],
subject: `RSS Update ${(new Date()).toDateString()}`,
html,
});
};
👆 This is a val. Vals are TypeScript snippets of code, written in the browser and run on our servers. Create scheduled functions, email yourself, and persist small pieces of data — all from the browser.