Migrate to typescript

This commit is contained in:
prototypa
2023-01-02 10:51:51 -05:00
parent ba0e67b55f
commit f158d32181
28 changed files with 172 additions and 85 deletions

29
src/pages/rss.xml.ts Normal file
View File

@ -0,0 +1,29 @@
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.publishDate,
})),
});
};