mirror of
https://github.com/rustdesk/doc.rustdesk.com.git
synced 2026-04-20 15:10:14 +00:00
initialize with https://github.com/onwidget/astrowind
This commit is contained in:
37
v3/src/pages/rss.xml.ts
Normal file
37
v3/src/pages/rss.xml.ts
Normal file
@@ -0,0 +1,37 @@
|
||||
import { getRssString } from '@astrojs/rss';
|
||||
|
||||
import { SITE, METADATA, APP_BLOG } from 'astrowind:config';
|
||||
import { fetchPosts } from '~/utils/blog';
|
||||
import { getPermalink } from '~/utils/permalinks';
|
||||
|
||||
export const GET = async () => {
|
||||
if (!APP_BLOG.isEnabled) {
|
||||
return new Response(null, {
|
||||
status: 404,
|
||||
statusText: 'Not found',
|
||||
});
|
||||
}
|
||||
|
||||
const posts = await fetchPosts();
|
||||
|
||||
const rss = await getRssString({
|
||||
title: `${SITE.name}’s Blog`,
|
||||
description: METADATA?.description || '',
|
||||
site: import.meta.env.SITE,
|
||||
|
||||
items: posts.map((post) => ({
|
||||
link: getPermalink(post.permalink, 'post'),
|
||||
title: post.title,
|
||||
description: post.excerpt,
|
||||
pubDate: post.publishDate,
|
||||
})),
|
||||
|
||||
trailingSlash: SITE.trailingSlash,
|
||||
});
|
||||
|
||||
return new Response(rss, {
|
||||
headers: {
|
||||
'Content-Type': 'application/xml',
|
||||
},
|
||||
});
|
||||
};
|
||||
Reference in New Issue
Block a user