Skip to content

Instantly share code, notes, and snippets.

@blackspike
Created June 20, 2023 13:40
Show Gist options
  • Save blackspike/60284b5617f5e446024e0d776f6152ff to your computer and use it in GitHub Desktop.
Save blackspike/60284b5617f5e446024e0d776f6152ff to your computer and use it in GitHub Desktop.
import rss from "@astrojs/rss"
import { getCollection } from "astro:content"
export async function get(context) {
const blog = await getCollection("blog")
return rss({
title: "blackspike blog",
description: "thoughts from blackspike",
site: context.site,
stylesheet: "/rss-styles.xsl",
items: blog
.filter((post) => !post.data.draft)
.sort((a, b) => a.data.date - b.data.date)
.reverse()
.map((post) => ({
title: post.data.title,
pubDate: post.data.date,
description: post.data.description,
link: `/blog/${post.slug}/`,
})),
})
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment