Skip to content

Commit 829d3ae

Browse files
committed
feat(rss): add filename to config
Allow the name of the file that the feeds will use to be set using config
1 parent e00bc68 commit 829d3ae

2 files changed

Lines changed: 10 additions & 7 deletions

File tree

plugins/rss/src/rss.js

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ const { log, logError, yellow } = require('@scullyio/scully');
77
const configFile = readFileSync(`${process.cwd()}/rss.config.json`, 'utf8');
88
const config = JSON.parse(configFile.toString());
99
const blogPostRouteSlug = config.blogPostRouteSlug || '/blog';
10+
const filename = config.filename || 'feed';
1011
const feed = new Feed(config);
1112

1213
config.categories.forEach((cat) => {
@@ -42,12 +43,12 @@ const rssPlugin = (routes) => {
4243
feed.addItem(item);
4344
});
4445
try {
45-
writeFileSync(join(config.outDir || '', 'feed.xml'), feed.rss2());
46-
log(`✅ Created ${yellow(config.outDir + '/feed.xml')}`);
47-
writeFileSync(join(config.outDir || '', 'feed.atom'), feed.atom1());
48-
log(`✅ Created ${yellow(config.outDir + '/feed.atom')}`);
49-
writeFileSync(join(config.outDir || '', 'feed.json'), feed.json1());
50-
log(`✅ Created ${yellow(config.outDir + '/feed.json')}`);
46+
writeFileSync(join(config.outDir || '', `${filename}.xml`), feed.rss2());
47+
log(`✅ Created ${yellow(config.outDir + `/${filename}.xml`)}`);
48+
writeFileSync(join(config.outDir || '', `${filename}.atom`), feed.atom1());
49+
log(`✅ Created ${yellow(config.outDir + `/${filename}.atom`)}`);
50+
writeFileSync(join(config.outDir || '', `${filename}.json`), feed.json1());
51+
log(`✅ Created ${yellow(config.outDir + `/${filename}.json`)}`);
5152
} catch (error) {
5253
logError('❌ Failed to create RSS feed. Error:', error);
5354
throw error;

rss.config.json

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,11 @@
88
"favicon": "https://notiz.dev/favicon.png",
99
"copyright": "2020 notiz.dev",
1010
"generator": "Weeklyish Articles about Web Development",
11+
"filename": "feed",
1112
"feedLinks": {
13+
"atom": "https://notiz.dev/feed.atom",
1214
"json": "https://notiz.dev/feed.json",
13-
"atom": "https://notiz.dev/feed.atom"
15+
"xml": "https://notiz.dev/feed.xml"
1416
},
1517
"outDir": "./dist/static",
1618
"categories": ["Web Development", "Blog", "Angular", "node"]

0 commit comments

Comments
 (0)