--- import BaseLayout from '../../layouts/BaseLayout.astro'; import { getCollection } from 'astro:content'; // 获取所有非草稿文章 const allPosts = await getCollection('blog', ({ data }) => { return !data.draft; }); // 按日期排序 const sortedPosts = allPosts.sort((a, b) => b.data.pubDate.valueOf() - a.data.pubDate.valueOf() ); // 格式化日期 const formatDate = (date: Date) => { return date.toLocaleDateString('zh-CN', { year: 'numeric', month: 'long', day: 'numeric', }); }; ---