Files
blog/src/pages/rss.xml.js
2022-09-04 00:56:24 -04:00

29 lines
664 B
JavaScript
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

import rss from "@astrojs/rss";
import { SITE, BLOG } from "~/config.mjs";
import { fetchPosts } from "~/utils/posts";
import { getPermalink } from "~/utils/permalinks";
export const get = async () => {
if (BLOG.disabled) {
return new Response(null, {
status: 404,
statusText: 'Not found'
});
}
const posts = await fetchPosts();
return rss({
title: `${SITE.name}s Blog`,
description: SITE.description,
site: import.meta.env.SITE,
items: posts.map((post) => ({
link: getPermalink(post.slug, "post"),
title: post.title,
description: post.description,
pubDate: post.pubDate,
})),
});
}