-
Notifications
You must be signed in to change notification settings - Fork 6
/
feed.ts
45 lines (40 loc) · 1 KB
/
feed.ts
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
36
37
38
39
40
41
42
43
44
45
import { Feed } from "./deps/feed.ts";
import { Page, UserConfig } from "./types.d.ts";
interface FeedOpts {
userConfig: UserConfig;
pages: Page[];
}
export const generateFeed = (opts: FeedOpts): Feed => {
const { userConfig, pages } = opts;
const { title, description, url, lang, authorName, authorEmail, authorUrl } =
userConfig;
const feed = new Feed({
title,
description,
id: url,
link: url,
language: lang?.toString() || "en",
// image: site.url,
// favicon: site.url,
copyright: `Copyright ${new Date().getFullYear()} ${url}`,
feedLinks: {
atom: `${url}/feed`,
},
author: {
name: authorName,
email: authorEmail,
link: authorUrl,
},
});
pages.forEach((page) => {
feed.addItem({
title: page.title || "",
id: page.url.toString(),
link: page.url.toString(),
description: page.description,
content: page.html || "",
date: page.datePublished || new Date(),
});
});
return feed;
};