summaryrefslogtreecommitdiff
path: root/src/pages/rss.xml.js
diff options
context:
space:
mode:
authorJoe Carstairs <65492573+Sycamost@users.noreply.github.com>2024-03-30 16:32:17 +0000
committerJoe Carstairs <65492573+Sycamost@users.noreply.github.com>2024-03-30 16:43:22 +0000
commit261d89ebed13691e72312f44339063fee93130ac (patch)
tree43cb6f1a9804352f666efaaee2bf7d6189906f08 /src/pages/rss.xml.js
parent9cb047768f79f3d14a5c6bcf420e76d600a20f2d (diff)
Astro initial commit
Diffstat (limited to 'src/pages/rss.xml.js')
-rw-r--r--src/pages/rss.xml.js17
1 files changed, 17 insertions, 0 deletions
diff --git a/src/pages/rss.xml.js b/src/pages/rss.xml.js
new file mode 100644
index 0000000..79da596
--- /dev/null
+++ b/src/pages/rss.xml.js
@@ -0,0 +1,17 @@
+import rss from '@astrojs/rss';
+import { getCollection } from 'astro:content';
+import { SITE_TITLE, SITE_DESCRIPTION } from '../consts';
+
+export async function GET(context) {
+ const posts = await getCollection('blog');
+ return rss({
+ title: SITE_TITLE,
+ description: SITE_DESCRIPTION,
+ site: context.site,
+ items: posts.map((post) => ({
+ ...post.data,
+ link: `/blog/${post.slug}/`,
+ pubDate: new Date(post.data.pubDate.year, post.data.pubDate.month - 1, post.data.pubDate.day),
+ })),
+ });
+}