diff --git a/package.json b/package.json index ed727d3..708788a 100644 --- a/package.json +++ b/package.json @@ -3,6 +3,7 @@ "version": "1.0.0", "description": "", "main": "site.config.js", + "type": "module", "scripts": { "build": "nanogen build", "start": "nanogen start", diff --git a/tools/rss-entries.js b/tools/rss-entries.js new file mode 100644 index 0000000..3956a45 --- /dev/null +++ b/tools/rss-entries.js @@ -0,0 +1,11 @@ +export const feed = [[ + '2021-10-02', + 'https://oddsquat.org/1', + 'Second Item Title', + 'Use this for the content. It can include html.' +], [ + '2021-10-01', + 'https://oddsquat.org/2', + 'First Item Title', + 'Use this for the content. It can include html.' +]] diff --git a/tools/rss.js b/tools/rss.js index adf60cb..312b0a6 100644 --- a/tools/rss.js +++ b/tools/rss.js @@ -1,17 +1,8 @@ -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.' -]] +import rss from 'rss-generator' +import { feed } from './rss-entries.js' const url = 'https://oddsquat.org' -const rssFeed = new (require('rss-generator'))({ +const rssFeed = new rss({ title: 'oddsquat', site_url: `${url}`, feed_url: `${url}/rss.xml`, @@ -22,11 +13,11 @@ const rssFeed = new (require('rss-generator'))({ feed.forEach(([date, url, title, description]) => rssFeed.item({date, url, title, description})) -const fs = require('fs') +import { writeFile } from 'fs' const RSS_FILEPATH = './src/assets/rss.xml' -void fs.writeFile( +void writeFile( RSS_FILEPATH, rssFeed.xml(), err => err