1const fs = require("fs");
2const path = require("path");
3const matter = require("gray-matter");
4const toml = require("@iarna/toml");
5const Feed = require("feed").Feed;
9 toml: toml.parse.bind(toml),
15const 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)),
27 const leadingDir = dir.substr(dir.indexOf("content") + 8);
28 const name = post.name.replace(/.md$/, "");
31 title: pageData.title,
32 descripton: pageData.description || "",
33 author: pageData.extra ? pageData.extra.author || "" : "",
34 date: pageData.date || pageData.starts,
35 link: `https://urbit.org/${leadingDir}/${name}`,
41 ...getAllChildren(path.join(process.cwd(), "content/blog")),
42 ...getAllChildren(path.join(process.cwd(), "content/updates")),
43 ...getAllChildren(path.join(process.cwd(), "content/events"))
45 posts = posts.sort((a, b) => (a.date > b.date ? -1 : 1));
47 const baseUrl = "https://urbit.org";
50 email: "support@urbit.org",
51 link: "https://urbit.org",
54 // Construct a new Feed object
55 const feed = new Feed({
57 description: "Urbit is a personal server built from scratch",
62 rss2: `${baseUrl}/rss.xml`,
67 // Add each article to the feed
68 posts.forEach((post) => {
69 const { title, description, author, date, link, content } = post;
87 fs.readdirSync("public");
89 fs.mkdirSync("public");
92 fs.writeFileSync("public/rss.xml", feed.rss2());
keysesc to close
- j k
- move down, up
- enter
- open
- esc
- back, or up a level
- 1 2 3 4
- readme, files, commits, refs
- /
- filter
- y
- copy the clone command
- c
- compare the chosen commit with another (or shift-click both)
- ?
- show or hide this list