mirror of
https://github.com/afoim/fuwari.git
synced 2026-01-31 09:03:18 +08:00
refactor(rss): 使用统一的文章排序逻辑
从直接获取文章集合改为使用 getSortedPosts 工具函数,确保 RSS 订阅中的文章排序与网站列表保持一致(置顶文章优先,然后按发布时间降序)
This commit is contained in:
@@ -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) {
|
||||
|
||||
Reference in New Issue
Block a user