docs: update rss to use autogenerated from starlight-blog (#2165)

Co-authored-by: Simon Hyll <hyllsimon@gmail.com>
This commit is contained in:
Vitor Ayres
2024-05-21 08:51:03 -03:00
committed by GitHub
parent b140d98e7c
commit c129af5233
3 changed files with 4 additions and 34 deletions

View File

@@ -4,6 +4,9 @@
/ko/* /:splat 302
/it/* /:splat 302
# blog rss
/blog.xml /blog/rss.xml 301
# Docs rework
/guides /start 301

View File

@@ -6,5 +6,5 @@ i18nReady: true
import { LinkCard } from '@astrojs/starlight/components';
<LinkCard title="All updates" href="/feed.xml" />
<LinkCard title="Blog updates" href="/blog.xml" />
<LinkCard title="Blog updates" href="/blog/rss.xml" />
<LinkCard title="Pages updates" href="/pages.xml" />

View File

@@ -1,33 +0,0 @@
// This RSS includes only blog pages
import rss from '@astrojs/rss';
import { getCollection } from 'astro:content';
import type { APIContext } from 'astro';
// https://docs.astro.build/en/reference/api-reference/#endpoint-context
export async function GET(context: APIContext) {
const posts = await getCollection('docs', ({ id }) => {
return id.startsWith('blog');
});
posts.sort((a, b) => {
const dateA = a.data.date;
const dateB = b.data.date;
if (dateA && dateB) {
if (dateA < dateB) return 1;
if (dateA > dateB) return -1;
return 0;
} else return 0;
});
return rss({
title: 'Tauri Blog',
description: 'The cross-platform app building toolkit',
site: context.site as URL,
items: posts.map((post) => ({
pubDate: post.data.date,
description: post.data.excerpt,
...post.data,
link: `/${post.slug}/`,
})),
});
}