-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathfeed.js
35 lines (30 loc) · 849 Bytes
/
feed.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
import { Feed } from "feed";
export function generateFeed(posts, metadata) {
const site_url = "https://lightasbird.xyz/";
const feedOptions = {
author: {
name: "Yipu Zhang",
email: "[email protected]",
link: site_url,
},
description: metadata.description,
favicon: `${site_url}/icon.png`,
feedLinks: { atom: `${site_url}atom.xml`, rss: `${site_url}rss.xml` },
generator: "Feed for Node.js",
id: site_url,
image: "https://github.com/breeze2501.png",
link: site_url,
title: metadata.title,
};
const feed = new Feed(feedOptions);
for (const post of posts) {
feed.addItem({
date: new Date(post.date),
description: post.spoiler,
id: `${site_url}${post.slug}/`,
link: `${site_url}${post.slug}/`,
title: post.title,
});
}
return feed;
}