From c80ada6af52576d03a30983d776ccb32218502a0 Mon Sep 17 00:00:00 2001 From: lzy Date: Thu, 23 Jul 2026 19:15:27 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E9=A6=96=E9=A1=B5=E4=B8=8E=E6=96=B0?= =?UTF-8?q?=E9=97=BB=E5=88=97=E8=A1=A8/=E8=AF=A6=E6=83=85=E9=A1=B5?= =?UTF-8?q?=E9=9D=A2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/layouts/BaseLayout.astro | 19 +++++++++++++++++++ src/pages/index.astro | 21 +++++++++++++++++++++ src/pages/news/[slug].astro | 23 +++++++++++++++++++++++ src/pages/news/index.astro | 19 +++++++++++++++++++ 4 files changed, 82 insertions(+) create mode 100644 src/layouts/BaseLayout.astro create mode 100644 src/pages/index.astro create mode 100644 src/pages/news/[slug].astro create mode 100644 src/pages/news/index.astro diff --git a/src/layouts/BaseLayout.astro b/src/layouts/BaseLayout.astro new file mode 100644 index 0000000..63bdb3e --- /dev/null +++ b/src/layouts/BaseLayout.astro @@ -0,0 +1,19 @@ +--- +import '../styles/global.css'; +interface Props { title: string; } +const { title } = Astro.props; +--- + + + + + + + {title} + + +
官网基座
+
+ + + diff --git a/src/pages/index.astro b/src/pages/index.astro new file mode 100644 index 0000000..a5d2b47 --- /dev/null +++ b/src/pages/index.astro @@ -0,0 +1,21 @@ +--- +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() +); +--- + +

官网基座

+

Phase 0 技术验证站点。

+
+

最新动态

+
    + {news.map((post) => ( +
  • {post.data.title} {post.data.date.toLocaleDateString('zh-CN')}
  • + ))} +
+

查看全部 →

+
+
diff --git a/src/pages/news/[slug].astro b/src/pages/news/[slug].astro new file mode 100644 index 0000000..e7dace2 --- /dev/null +++ b/src/pages/news/[slug].astro @@ -0,0 +1,23 @@ +--- +import BaseLayout from '../../layouts/BaseLayout.astro'; +import { getCollection, render } from 'astro:content'; + +export async function getStaticPaths() { + const news = await getCollection('news'); + return news.map((post) => ({ + params: { slug: post.id }, + props: { post }, + })); +} + +const { post } = Astro.props; +const { Content } = await render(post); +--- + +
+

{post.data.title}

+

{post.data.category} · {post.data.date.toLocaleDateString('zh-CN')}

+ +
+

← 返回列表

+
diff --git a/src/pages/news/index.astro b/src/pages/news/index.astro new file mode 100644 index 0000000..d286a00 --- /dev/null +++ b/src/pages/news/index.astro @@ -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() +); +--- + +

新闻动态

+ +