From 829d3ae460e4bb2211c51b48ba5642cbd583f3cf Mon Sep 17 00:00:00 2001 From: Preston Lamb Date: Fri, 27 Nov 2020 20:03:57 -0700 Subject: [PATCH 1/2] feat(rss): add filename to config Allow the name of the file that the feeds will use to be set using config --- plugins/rss/src/rss.js | 13 +++++++------ rss.config.json | 4 +++- 2 files changed, 10 insertions(+), 7 deletions(-) diff --git a/plugins/rss/src/rss.js b/plugins/rss/src/rss.js index d2458a5..f4eac49 100644 --- a/plugins/rss/src/rss.js +++ b/plugins/rss/src/rss.js @@ -7,6 +7,7 @@ const { log, logError, yellow } = require('@scullyio/scully'); const configFile = readFileSync(`${process.cwd()}/rss.config.json`, 'utf8'); const config = JSON.parse(configFile.toString()); const blogPostRouteSlug = config.blogPostRouteSlug || '/blog'; +const filename = config.filename || 'feed'; const feed = new Feed(config); config.categories.forEach((cat) => { @@ -42,12 +43,12 @@ const rssPlugin = (routes) => { feed.addItem(item); }); try { - writeFileSync(join(config.outDir || '', 'feed.xml'), feed.rss2()); - log(`✅ Created ${yellow(config.outDir + '/feed.xml')}`); - writeFileSync(join(config.outDir || '', 'feed.atom'), feed.atom1()); - log(`✅ Created ${yellow(config.outDir + '/feed.atom')}`); - writeFileSync(join(config.outDir || '', 'feed.json'), feed.json1()); - log(`✅ Created ${yellow(config.outDir + '/feed.json')}`); + writeFileSync(join(config.outDir || '', `${filename}.xml`), feed.rss2()); + log(`✅ Created ${yellow(config.outDir + `/${filename}.xml`)}`); + writeFileSync(join(config.outDir || '', `${filename}.atom`), feed.atom1()); + log(`✅ Created ${yellow(config.outDir + `/${filename}.atom`)}`); + writeFileSync(join(config.outDir || '', `${filename}.json`), feed.json1()); + log(`✅ Created ${yellow(config.outDir + `/${filename}.json`)}`); } catch (error) { logError('❌ Failed to create RSS feed. Error:', error); throw error; diff --git a/rss.config.json b/rss.config.json index d570890..cc343e9 100644 --- a/rss.config.json +++ b/rss.config.json @@ -8,9 +8,11 @@ "favicon": "https://notiz.dev/favicon.png", "copyright": "2020 notiz.dev", "generator": "Weeklyish Articles about Web Development", + "filename": "feed", "feedLinks": { + "atom": "https://notiz.dev/feed.atom", "json": "https://notiz.dev/feed.json", - "atom": "https://notiz.dev/feed.atom" + "xml": "https://notiz.dev/feed.xml" }, "outDir": "./dist/static", "categories": ["Web Development", "Blog", "Angular", "node"] From 24449b4ae7745a82b83706d789b517fcf53d66e3 Mon Sep 17 00:00:00 2001 From: Preston Lamb Date: Fri, 27 Nov 2020 21:18:36 -0700 Subject: [PATCH 2/2] docs(rss): add docs about filename Add to the docs that the filename for the feed can be changed with config --- plugins/rss/README.md | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/plugins/rss/README.md b/plugins/rss/README.md index 426394d..219609c 100644 --- a/plugins/rss/README.md +++ b/plugins/rss/README.md @@ -10,6 +10,8 @@ The rss feed is available at: - your-domain.de/feed.atom - your-domain.de/feed.xml +To change the filename of the feed, use the `filename` attribute in your rss.config.json file, as seen below. The default value is feed, but you can change it to whatever you'd like. + > **Breaking Change** introduced in Version 1.0.0 with changing the plugin type from `render` to `routeDiscoveryDone`. This has the major benefit of only generating the RSS Feed once per run instead of after each page render. ## 📦 Installation @@ -53,9 +55,11 @@ Create a `rss.config.json` in your root with the following properties: "favicon": "https://you-domain.com/favicon.png", "copyright": "2020 your-domain.com", "generator": "Page description", + "filename": "feed", "feedLinks": { + "atom": "https://your-domain.com/feed.atom", "json": "https://your-domain.com/feed.json", - "atom": "https://your-domain.com/feed.atom" + "xml": "https://your-domain.com/feed.xml" }, "outDir": "./dist/static", "categories": ["Categories", "of", "your", "choice"],