and you're not
Pinging RSSCloud with a static blog
November 23, 2022 by Scott Hanson

One way to connect a blog to RSS readers and communities (like FeedLand) is to ping an RSSCloud server whenever your feed changes. But with the Jamstack model of triggering deploys to a static site hoster, I wasn’t sure how to implement that, and a web search did not offer much help.

n

However, my hoster Netlify offers serverless functions (as do similar hosters like Vercel, Cloudflare Pages, DigitalOcean Apps, etc.). Specifically, I can run a function on a “deploy-successful” event, so I know the blog has just been rebuilt. RSSCloud expects a POST request, so I can send that off with node-fetch.

n
const fetch = require('node-fetch')nnconst handler = async function (_event, _context) {n    try {n        const params = new URLSearchParams()n        params.append('url', 'https://scotthanson.de/feed.xml')nn        const response = await fetch('http://rpc.rsscloud.io:5337/ping', {n            method: 'POST',n            headers: { Accept: 'application/json' },n            body: params,n        })n        const data = await response.json()n        console.log(data)n    } catch (error) {n        // output to netlify function logn        console.log(error)n    }n}nnmodule.exports = { handler }n
n

Now RSS readers that listen to RSSCloud servers will know about changes to my feed within seconds.

]]>

Last update: 11/23/22; 1:00:00 AM.