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 技术验证站点。

+
+

最新动态

+ +

查看全部 →

+
+
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() +); +--- + +

新闻动态

+ +