Adding the cloud element to RSS

Oct 12, 2024

2 min read

Scott Hanson

The blog generator bloggrify is based on nuxt-content and generates a RSS feed as a server route in nuxtjs using the feed package from npm. However, try as I may, I was unable to add the cloud element to the feed. The cloud element is used to notify feed readers (like FeedLand) that the feed has been updated. It's a standard element for RSS, and I was surprised it could not simply be added to the generating the feed.

I ended up rewriting the route using jstoxml so I can choose my own elements.

import jstoxml from 'jstoxml'
const { toXML } = jstoxml
// config contains data for title, description, etc.
const content = {
    _name: 'rss',
    _attrs: {
        version: '2.0',
    },
    _content: {
        channel: [
            { title: config.name },
            { description: config.description },
            { link: url },
            { docs: 'http://cyber.law.harvard.edu/rss/rss.html' },
            { language: config.language },
            { favicon: url + '/favicon.ico' },
            { copyright: `All rights reserved ${now.getFullYear()}, ${config.name}` },
            { generator: 'bloggrify-smh' },
            {
                _name: 'cloud',
                _attrs: {
                    domain: 'rpc.rsscloud.io',
                    port: 5337,
                    path: '/pleaseNotify',
                    registerProcedure: 'http-post',
                },
            },
        ],
    },
}
// After adding items content (code omitted), generate the feed
const configXML = {
    indent: '  ',
}
return toXML(content, configXML)

FeedLand seems to accept the feed, and this post will be a test of whether the ping goes through or not. 😃

Update It worked! rsscloud.io was pinged, and FeedLand updated the feed.

Screenshot showing FeedLand updated the feed
Screenshot showing FeedLand updated the feed