refactor(rss): 使用统一的文章排序逻辑

从直接获取文章集合改为使用 getSortedPosts 工具函数,确保 RSS 订阅中的文章排序与网站列表保持一致(置顶文章优先,然后按发布时间降序)
This commit is contained in:
afoim
2025-08-10 22:52:45 +08:00
parent 4667fb2032
commit 8fdf9f49f8

View File

@@ -5,8 +5,9 @@ import { getCollection } from 'astro:content';
import { siteConfig } from '@/config';
import { parse as htmlParser } from 'node-html-parser';
import { getImage } from 'astro:assets';
import type { APIContext } from 'astro';
import type { APIContext, ImageMetadata } from 'astro';
import type { RSSFeedItem } from '@astrojs/rss';
import { getSortedPosts } from '@/utils/content-utils';
const markdownParser = new MarkdownIt();
@@ -20,7 +21,8 @@ export async function GET(context: APIContext) {
throw Error('site not set');
}
const posts = await getCollection('posts');
// Use the same ordering as site listing (pinned first, then by published desc)
const posts = await getSortedPosts();
const feed: RSSFeedItem[] = [];
for (const post of posts) {