-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcontent.config.ts
More file actions
38 lines (35 loc) · 907 Bytes
/
Copy pathcontent.config.ts
File metadata and controls
38 lines (35 loc) · 907 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
import { defineCollection, defineContentConfig, z } from '@nuxt/content'
// 与 meta/taxonomy.json v1.0.0 保持一致,改动分类须同步两处
const CATEGORIES = [
'source-code',
'devops',
'visualization',
'standards',
'fundamentals',
'toolchain',
'interview'
] as const
// 博客与文档共用的 frontmatter 约束
const baseSchema = {
title: z.string(),
description: z.string(),
date: z.string().regex(/^\d{4}-\d{2}-\d{2}$/),
category: z.enum(CATEGORIES),
tags: z.array(z.string()).default([]),
draft: z.boolean().default(false),
source: z.string().optional()
}
export default defineContentConfig({
collections: {
blog: defineCollection({
type: 'page',
source: 'blog/**/*.md',
schema: z.object(baseSchema)
}),
docs: defineCollection({
type: 'page',
source: 'docs/**/*.md',
schema: z.object(baseSchema)
})
}
})