-
Notifications
You must be signed in to change notification settings - Fork 7
Expand file tree
/
Copy pathcontent.config.ts
More file actions
48 lines (45 loc) · 1.32 KB
/
content.config.ts
File metadata and controls
48 lines (45 loc) · 1.32 KB
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
39
40
41
42
43
44
45
46
47
48
import { defineCollection, defineContentConfig, z } from '@nuxt/content';
import type { DefinedCollection } from '@nuxt/content';
import { nuxtI18nLocales, i18nCodeToContent } from './i18n/config';
import type { NuxtI18nCode, NuxtI18nContentCode } from './i18n/config';
const pageSchama = z.object({
title: z.string(),
date: z.date(),
categories: z.array(z.string()),
important: z.optional(z.boolean()),
home: z.optional(z.boolean())
});
const definePageCollection = (locale: NuxtI18nCode) =>
defineCollection({
source: {
include: `${locale}/**`,
prefix: '/', // prefixes are handled by @nuxtjs/i18n
exclude: ['**/_*']
},
type: 'page',
schema: pageSchama
});
export default defineContentConfig({
collections: {
...Object.fromEntries(
nuxtI18nLocales.map((locale) => [
i18nCodeToContent(locale.code),
definePageCollection(locale.code)
])
),
gallery: defineCollection({
source: 'all/gallery.yml',
type: 'data',
schema: z.object({
gallery: z.array(
z.object({
title: z.string(),
album: z.array(
z.object({ desc: z.string(), date: z.string(), file: z.string() })
)
})
)
})
})
} as { [key in NuxtI18nContentCode | 'gallery']: DefinedCollection }
});