Edit on val.town ↗

RSS

Val Town can both parse and generate RSS feeds for blogs and other updated sources.

You would run this example in Val Town using a Cron trigger that ran on a regular interval, and it would check a blog's feed every 15 minutes.

import { email } from "https://esm.town/v/std/email?v=9";
import { newRSSItems } from "https://esm.town/v/stevekrouse/newRSSItems";
import { rssFeeds } from "https://esm.town/v/stevekrouse/rssFeeds";

export async function pollRSSFeeds({ lastRunAt }: Interval) {
  return Promise.all(
    Object.entries(rssFeeds).map(async ([name, url]) => {
      let items = await newRSSItems({
        url,
        lastRunAt,
      });
      if (items.length)
        await email({
          text: JSON.stringify(items, null, 2),
          subject: `New from ${name} RSS`,
        });
      return { name, items };
    })
  );
}

Last updated