Skip to content

Commit 4f59694

Browse files
authored
Merge pull request #1062 from AvdLee/add-blog-rss-feed
Add blog RSS feed
2 parents a719644 + 9b3be27 commit 4f59694

4 files changed

Lines changed: 173 additions & 0 deletions

File tree

docs/package-lock.json

Lines changed: 141 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

docs/package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
"dependencies": {
1818
"@astrojs/mdx": "^4.3.13",
1919
"@astrojs/react": "^4.4.2",
20+
"@astrojs/rss": "^4.0.18",
2021
"@astrojs/sitemap": "^3.5.1",
2122
"@astrojs/starlight": "^0.37.3",
2223
"aos": "^2.3.4",

docs/src/layouts/components/SEO.astro

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -117,6 +117,12 @@ const ogType = article ? "article" : "website";
117117

118118
<!-- Canonical URL -->
119119
<link rel="canonical" href={canonicalUrl} />
120+
<link
121+
rel="alternate"
122+
type="application/rss+xml"
123+
title="RocketSim Blog"
124+
href="/rss.xml"
125+
/>
120126
<link rel="alternate" type="text/plain" title="LLMs" href="/llms.txt" />
121127
<link
122128
rel="alternate"

docs/src/pages/rss.xml.ts

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
import rss from "@astrojs/rss";
2+
import { getCollection } from "astro:content";
3+
4+
import config from "@/config/config.json";
5+
6+
export async function GET(context: { site?: URL }) {
7+
const posts = await getCollection("blog");
8+
const site = context.site?.toString() ?? config.site.base_url;
9+
10+
return rss({
11+
title: "RocketSim Blog",
12+
description:
13+
"Tips, guides, and deep dives for iOS developers who want to move faster.",
14+
site,
15+
customData: "<language>en</language>",
16+
items: posts
17+
.map((post) => ({
18+
title: post.data.title,
19+
description: post.data.description,
20+
pubDate: post.data.modifiedTime ?? post.data.publishedTime,
21+
link: `/blog/${post.id}/`,
22+
}))
23+
.sort((a, b) => b.pubDate.getTime() - a.pubDate.getTime()),
24+
});
25+
}

0 commit comments

Comments
 (0)