Skip to content

Commit 520be1a

Browse files
authored
Merge pull request #21 from pjlamb12/filename-config
Filename Set from Config
2 parents e00bc68 + 24449b4 commit 520be1a

3 files changed

Lines changed: 15 additions & 8 deletions

File tree

plugins/rss/README.md

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,8 @@ The rss feed is available at:
1010
- your-domain.de/feed.atom
1111
- your-domain.de/feed.xml
1212

13+
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.
14+
1315
> **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.
1416
1517
## 📦 Installation
@@ -53,9 +55,11 @@ Create a `rss.config.json` in your root with the following properties:
5355
"favicon": "https://you-domain.com/favicon.png",
5456
"copyright": "2020 your-domain.com",
5557
"generator": "Page description",
58+
"filename": "feed",
5659
"feedLinks": {
60+
"atom": "https://your-domain.com/feed.atom",
5761
"json": "https://your-domain.com/feed.json",
58-
"atom": "https://your-domain.com/feed.atom"
62+
"xml": "https://your-domain.com/feed.xml"
5963
},
6064
"outDir": "./dist/static",
6165
"categories": ["Categories", "of", "your", "choice"],

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)