radiatingstar/radiatingstar.com

View on GitHub
src/pages/rss.xml.js

Summary

Maintainability
A
0 mins
Test Coverage
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.date),
    })),
  });
}