fix: rss feed prop should not be global
This commit is contained in:
parent
11f73d8011
commit
80023dbd6a
45
utils/rss.ts
45
utils/rss.ts
|
@ -6,30 +6,31 @@ import { METADATA } from '@/constants';
|
|||
import rimraf from 'rimraf';
|
||||
|
||||
const baseUrl = METADATA.HOST_URL;
|
||||
const date = new Date();
|
||||
const feed = new Feed({
|
||||
title: METADATA.TITLE,
|
||||
description: METADATA.DESCRIPTION,
|
||||
id: `${baseUrl}/`,
|
||||
link: baseUrl,
|
||||
language: 'en', // optional, used only in RSS 2.0, possible values: http://www.w3.org/TR/REC-html40/struct/dirlang.html#langcodes
|
||||
image: `${baseUrl}/android-chrome-192x192.png`,
|
||||
favicon: `${baseUrl}/favicon.ico`,
|
||||
copyright: `All rights reserved ${date.getFullYear()}, OPTF`,
|
||||
updated: date, // optional, default = today
|
||||
generator: 'Next.js using Feed for Node.js', // optional, default = 'Feed for Node.js'
|
||||
feedLinks: {
|
||||
rss2: `${baseUrl}/rss/feed.xml`,
|
||||
json: `${baseUrl}/rss/feed.json`,
|
||||
atom: `${baseUrl}/rss/atom.xml`,
|
||||
},
|
||||
});
|
||||
|
||||
METADATA.TAGS.forEach(tag => {
|
||||
feed.addCategory(tag);
|
||||
});
|
||||
|
||||
export default function generateRSSFeed(posts: IPost[]) {
|
||||
const date = new Date();
|
||||
const feed = new Feed({
|
||||
title: METADATA.TITLE,
|
||||
description: METADATA.DESCRIPTION,
|
||||
id: `${baseUrl}/`,
|
||||
link: baseUrl,
|
||||
language: 'en', // optional, used only in RSS 2.0, possible values: http://www.w3.org/TR/REC-html40/struct/dirlang.html#langcodes
|
||||
image: `${baseUrl}/android-chrome-192x192.png`,
|
||||
favicon: `${baseUrl}/favicon.ico`,
|
||||
copyright: `All rights reserved ${date.getFullYear()}, OPTF`,
|
||||
updated: date, // optional, default = today
|
||||
generator: 'Next.js using Feed for Node.js', // optional, default = 'Feed for Node.js'
|
||||
feedLinks: {
|
||||
rss2: `${baseUrl}/rss/feed.xml`,
|
||||
json: `${baseUrl}/rss/feed.json`,
|
||||
atom: `${baseUrl}/rss/atom.xml`,
|
||||
},
|
||||
});
|
||||
|
||||
METADATA.TAGS.forEach(tag => {
|
||||
feed.addCategory(tag);
|
||||
});
|
||||
|
||||
posts.forEach(post => {
|
||||
const postLink = `${baseUrl}/blog/${post.slug}`;
|
||||
const postContent = `<p>${post.description}</p><p><a href="${postLink}">Read more</a></p>`;
|
||||
|
|
Loading…
Reference in New Issue