From 8fdf9f49f822cd92466dee6fd810157c81f6015a Mon Sep 17 00:00:00 2001 From: afoim Date: Sun, 10 Aug 2025 22:52:45 +0800 Subject: [PATCH] =?UTF-8?q?refactor(rss):=20=E4=BD=BF=E7=94=A8=E7=BB=9F?= =?UTF-8?q?=E4=B8=80=E7=9A=84=E6=96=87=E7=AB=A0=E6=8E=92=E5=BA=8F=E9=80=BB?= =?UTF-8?q?=E8=BE=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 从直接获取文章集合改为使用 getSortedPosts 工具函数,确保 RSS 订阅中的文章排序与网站列表保持一致(置顶文章优先,然后按发布时间降序) --- src/pages/rss.xml.ts | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/pages/rss.xml.ts b/src/pages/rss.xml.ts index 8a420ecea..d379cf800 100644 --- a/src/pages/rss.xml.ts +++ b/src/pages/rss.xml.ts @@ -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) {