feat: 新增 news 内容集合与 Zod schema(含单测)

This commit is contained in:
lzy
2026-07-23 19:14:38 +08:00
parent 3ecac5b757
commit eab95953bf
6 changed files with 402 additions and 1250 deletions
+10
View File
@@ -0,0 +1,10 @@
import { defineCollection } from 'astro:content';
import { glob } from 'astro/loaders';
import { newsSchema } from './content/schemas';
const news = defineCollection({
loader: glob({ pattern: '**/*.md', base: './src/content/news' }),
schema: newsSchema,
});
export const collections = { news };
+7
View File
@@ -0,0 +1,7 @@
---
title: 官网基座启动
date: 2026-07-23
category: 公告
---
这是 Phase 0 技术验证的第一条新闻。内容编辑链路跑通后,客户可在 Sveltia CMS 自助新增。
+7
View File
@@ -0,0 +1,7 @@
import { z } from 'zod';
export const newsSchema = z.object({
title: z.string(),
date: z.coerce.date(),
category: z.string().default('未分类'),
});