@@ -0,0 +1,97 @@
1+const fs = require("fs");
2+const path = require("path");
3+const matter = require("gray-matter");
4+const toml = require("@iarna/toml");
5+const Feed = require("feed").Feed;
9+ toml: toml.parse.bind(toml),
15+const generateRSSFeed = () => {
18+ const getAllChildren = (dir) => {
19+ const children = fs.readdirSync(dir, { withFileTypes: true });
21+ .filter((f) => f.isFile() && f.name !== "_index.md")
23+ const { data: pageData, content: pageContent } = matter(
24+ fs.readFileSync(path.join(dir, post.name)),
28+ title: pageData.title,
29+ descripton: pageData.description || "",
30+ author: pageData.extra.author || "",
33+ "https://urbit.org/",
34+ dir.substr(dir.indexOf("content") + 7),
36+ post.name.replace(/.md$/, "")
38+ content: pageContent,
43+ ...getAllChildren(path.join(process.cwd(), "content/blog")),
44+ ...getAllChildren(path.join(process.cwd(), "content/updates")),
45+ ...getAllChildren(path.join(process.cwd(), "content/events"))
47+ posts = posts.sort((a, b) => (a.date > b.date ? -1 : 1));
49+ const baseUrl = "https://urbit.org";
52+ email: "support@urbit.org",
53+ link: "https://urbit.org",
56+ // Construct a new Feed object
57+ const feed = new Feed({
59+ description: "Urbit is a personal server built from scratch",
64+ rss2: `${baseUrl}/rss.xml`,
69+ // Add each article to the feed
70+ posts.forEach((post) => {
71+ const { title, description, author, date, link, content } = post;
85+ date: new Date(date),
89+ fs.readdirSync("public");
91+ fs.mkdirSync("public");
94+ fs.writeFileSync("public/rss.xml", feed.rss2());