From 1025d5e3f2a6c37c7445da66465d0f81c6a94044 Mon Sep 17 00:00:00 2001 From: He4eT Date: Sat, 9 Oct 2021 17:08:09 +0500 Subject: [PATCH] rss: feed generator --- rss.js | 34 ++++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) create mode 100644 rss.js diff --git a/rss.js b/rss.js new file mode 100644 index 0000000..adf60cb --- /dev/null +++ b/rss.js @@ -0,0 +1,34 @@ +const feed = [[ + '2021-10-02', + 'http://example.com/article4?this&that', + 'item title', + 'use this for the content. It can include html.' +], [ + '2021-10-01', + 'http://example.com/arthat', + 'another item title', + 'another use this for the content. It can include html.' +]] + +const url = 'https://oddsquat.org' +const rssFeed = new (require('rss-generator'))({ + title: 'oddsquat', + site_url: `${url}`, + feed_url: `${url}/rss.xml`, + image_url: `${url}/icon.svg'`, + description: + 'Fanzine about experiments, code and other cyberpunk stuff'}) + +feed.forEach(([date, url, title, description]) => + rssFeed.item({date, url, title, description})) + +const fs = require('fs') +const RSS_FILEPATH = + './src/assets/rss.xml' + +void fs.writeFile( + RSS_FILEPATH, + rssFeed.xml(), + err => err + ? console.error(err) + : console.log(`Updated: ${RSS_FILEPATH}`))