feat: 新增 news 内容集合与 Zod schema(含单测)
This commit is contained in:
@@ -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 };
|
||||
@@ -0,0 +1,7 @@
|
||||
---
|
||||
title: 官网基座启动
|
||||
date: 2026-07-23
|
||||
category: 公告
|
||||
---
|
||||
|
||||
这是 Phase 0 技术验证的第一条新闻。内容编辑链路跑通后,客户可在 Sveltia CMS 自助新增。
|
||||
@@ -0,0 +1,7 @@
|
||||
import { z } from 'zod';
|
||||
|
||||
export const newsSchema = z.object({
|
||||
title: z.string(),
|
||||
date: z.coerce.date(),
|
||||
category: z.string().default('未分类'),
|
||||
});
|
||||
Reference in New Issue
Block a user