Initial commit
This commit is contained in:
commit
b3a42bb0c8
91 changed files with 9419 additions and 0 deletions
19
src/pages/rss.xml.js
Normal file
19
src/pages/rss.xml.js
Normal file
|
@ -0,0 +1,19 @@
|
|||
import rss from '@astrojs/rss';
|
||||
import { getCollection } from 'astro:content';
|
||||
import siteConfig from '../data/site-config.ts';
|
||||
import { sortItemsByDateDesc } from '../utils/data-utils.ts';
|
||||
|
||||
export async function GET(context) {
|
||||
const posts = (await getCollection('blog')).sort(sortItemsByDateDesc);
|
||||
return rss({
|
||||
title: siteConfig.title,
|
||||
description: siteConfig.description,
|
||||
site: context.site,
|
||||
items: posts.map((item) => ({
|
||||
title: item.data.title,
|
||||
description: item.data.excerpt,
|
||||
link: `/blog/${item.id}/`,
|
||||
pubDate: item.data.publishDate.setUTCHours(0)
|
||||
}))
|
||||
});
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue