feat: 首页与新闻列表/详情页面
This commit is contained in:
@@ -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>
|
||||
Reference in New Issue
Block a user