feat: 首页与新闻列表/详情页面

This commit is contained in:
lzy
2026-07-23 19:15:27 +08:00
parent eab95953bf
commit c80ada6af5
4 changed files with 82 additions and 0 deletions
+19
View File
@@ -0,0 +1,19 @@
---
import BaseLayout from '../../layouts/BaseLayout.astro';
import { getCollection } from 'astro:content';
const news = (await getCollection('news')).sort(
(a, b) => b.data.date.getTime() - a.data.date.getTime()
);
---
<BaseLayout title="新闻动态">
<h1>新闻动态</h1>
<ul>
{news.map((post) => (
<li>
<a href={`/news/${post.id}/`}>{post.data.title}</a>
<small> · {post.data.category} · {post.data.date.toLocaleDateString('zh-CN')}</small>
</li>
))}
</ul>
</BaseLayout>