Index / Snippets / Generating RSS, Atom and JSON feeds in N

Generating RSS, Atom and JSON feeds in NodeJS with the Feed module

One npm module maps your posts to RSS, Atom and JSON.

Answers
How do you generate an RSS feed with NodeJS?
Topics
blog · cloud · creating · howto · networking · programming · webdesign
Full article on willem.com
https://willem.com/en/2020-10-31_increase-traffic-to-your-blog-with-a-rss-feed/

Summary

Use the Feed module from npm. I added a generateFeeds() function to my NodeJS static site generator that maps my post fields (title, image URL, publishing date) to the RSS structure and writes RSS, Atom and JSON feeds.

Full text

RSS is technically a dialect of XML, and the specification is open and well documented. Before writing your own implementation, check what already exists: a well tested package beats a self-built one with undiscovered bugs. For NodeJS that package is the Feed module from npm, which generates RSS, Atom and JSON feeds. My blog runs on custom software that generates static HTML pages from a NodeJS back-end, so I added a generateFeeds() function to the static site generator. Its main job is mapping the fields in the RSS feed structure to my website's object model: the title of a post, the URL of an image, the publishing date. That is not hard to get right if your object model already references those fields.

Machine formats of this page