-
Notifications
You must be signed in to change notification settings - Fork 3
/
build-feed.ts
42 lines (37 loc) · 1.03 KB
/
build-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
import { Feed } from "feed";
import { promises as fs } from "fs";
import { getBlogData } from "utils/getBlogData";
export const generateRSSFeed = async () => {
const baseUrl = "https://www.ludusrusso.dev";
const author = {
name: "Ludovico Russo",
email: "[email protected]",
link: "https://twitter.com/ludusrusso",
};
const feed = new Feed({
title: "Blog di Ludovico Russo",
description: "Il mio blog sulle mie sperimentazioni",
id: baseUrl,
link: baseUrl,
language: "it",
feedLinks: {
rss2: `${baseUrl}/rss.xml`,
},
author,
copyright: "2016 - 2022 Ludovico Russo. All rights reserved.",
});
// Add each article to the feed
getBlogData().forEach((post) => {
const { postPath, date, description, title } = post.frontMatter;
const url = `${baseUrl}/${postPath}`;
feed.addItem({
title,
id: url,
link: url,
description,
author: [author],
date: new Date(date),
});
});
await fs.writeFile("./public/rss.xml", feed.rss2());
};