-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathrss.ts
50 lines (44 loc) · 1.57 KB
/
rss.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
46
47
48
49
50
import { allBlogs } from "content-collections";
import { Feed } from "feed";
import fs from "fs";
async function generateRSSFeed() {
const baseUrl = "https://lakshyasharma.dev";
const creator = "Lakshya Sharma";
const feed = new Feed({
title: "Blogs | Lakshya Sharma",
description:
"Hey! I am Lakshya Sharma, and its my personal blog where I share my learnings, experiences, and thought regarding the full stack web dev",
id: baseUrl,
link: baseUrl,
image: `${baseUrl}/assets/logo.png`,
favicon: `${baseUrl}/assets/favicon.png`,
feed: `${baseUrl}/rss.xml`,
author: {
name: creator,
email: "[email protected]",
link: baseUrl,
},
language: "en-US",
copyright: `All Rights Reserved ${new Date().getFullYear()}, ${creator}`,
feedLinks: {
rss2: `${baseUrl}/rss.xml`,
json: `${baseUrl}/rss.json`,
atom: `${baseUrl}/atom.xml`,
},
});
feed.addCategory("Web Development");
feed.addCategory("Next.js");
allBlogs.map((blog) => {
feed.addItem({
title: blog.title,
description: blog.description,
link: `${baseUrl}${blog.url}`,
date: new Date(blog.date),
guid: blog.slug,
});
});
fs.writeFileSync("./public/rss.xml", feed.rss2());
fs.writeFileSync("./public/rss.json", feed.json1());
fs.writeFileSync("./public/atom.xml", feed.atom1());
}
generateRSSFeed().catch((err) => console.error(err));