From 0cd825af582f90fceb56f0d3a126341b1f600bfe Mon Sep 17 00:00:00 2001 From: skovati Date: Mon, 1 May 2023 00:27:05 -0500 Subject: [PATCH] add rss feed --- package.json | 1 + src/pages/intro.md | 4 ++-- src/pages/rss.xml.ts | 18 ++++++++++++++++++ 3 files changed, 21 insertions(+), 2 deletions(-) create mode 100644 src/pages/rss.xml.ts diff --git a/package.json b/package.json index e23db4e..64a75ba 100644 --- a/package.json +++ b/package.json @@ -10,6 +10,7 @@ "astro": "astro" }, "dependencies": { + "@astrojs/rss": "^2.4.0", "astro": "^2.3.0", "astro-compress": "^1.1.42" }, diff --git a/src/pages/intro.md b/src/pages/intro.md index 13f35f7..714f128 100644 --- a/src/pages/intro.md +++ b/src/pages/intro.md @@ -18,6 +18,6 @@ a few things i'm passionate about: professionally, i make computers go beep boop at a space science laboratory -check out my latest [blog posts](/posts) below or email me an encrypted message +check out my latest [blog posts](/posts) ([rss](/rss.xml)) below or email me an encrypted message -powered by free and open source software ([astro](https://astro.build/), [nginx](https://nginx.org/), [k3s](https://k3s.io/)) and self-hosted <3 +powered by free and open source software ([astro](https://astro.build), [debian](https://www.debian.org), [k3s](https://k3s.io), [nginx](https://nginx.org)) and self-hosted <3 diff --git a/src/pages/rss.xml.ts b/src/pages/rss.xml.ts new file mode 100644 index 0000000..f0d28d9 --- /dev/null +++ b/src/pages/rss.xml.ts @@ -0,0 +1,18 @@ +import rss from "@astrojs/rss"; +import { getCollection } from "astro:content"; + +export async function get() { + const posts = await getCollection('posts'); + return rss({ + title: "skovati.dev", + description: "hi, i'm skovati", + site: "https://skovati.dev", + items: posts.map(post => ({ + title: post.data.title, + pubDate: post.data.date, + desc: post.data.desc, + link: `/posts/${post.slug}/`, + })), + customData: `en-us`, + }); +} -- 2.38.5