-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcontent.config.ts
More file actions
116 lines (108 loc) · 3.51 KB
/
content.config.ts
File metadata and controls
116 lines (108 loc) · 3.51 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
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
// 1. Import utilities from `astro:content`
import {defineCollection, z, reference} from 'astro:content';
// 2. Import loader(s)
import {glob, file} from 'astro/loaders';
// 3. Define your collection(s)
const publications = defineCollection({
loader: file('./src/data/publications.json'),
schema: () =>
z.object({
id: z.number(), // mandatory
authors: z.string().nonempty(),
title: z.string().nonempty(),
url: z.string().url(),
source: z.string().nonempty(),
}),
});
const posts = defineCollection({
// loader: glob({pattern: '{de,en}/*.md', base: './src/posts'}),
schema: ({image}) =>
z.object({
title: z.string().nonempty(),
date: z.date(),
image: image(),
}),
});
const references = defineCollection({
// loader: glob({pattern: '{de,en}/*.md', base: './src/posts'}),
schema: ({image}) =>
z.object({
title: z.string().nonempty(),
image: image(),
}),
});
const services = defineCollection({
// loader: glob({pattern: '{de,en}/*.md', base: './src/services'}),
schema: () =>
z.object({
title: z.string().nonempty().max(100),
description: z.string().nonempty().max(250),
icon: z.string().nonempty(),
benefits: z.array(z.string().nonempty()).max(5),
references: z.array(reference('references')).max(5),
}),
});
const cookies = defineCollection({
loader: file('./src/data/cookies.json'),
schema: () =>
z.object({
id: z.string().nonempty(), // mandatory
de: z.object({
purpose: z.string().nonempty(),
validity: z.string().nonempty(),
}),
en: z.object({
purpose: z.string().nonempty(),
validity: z.string().nonempty(),
}),
}),
});
const data = defineCollection({
schema: ({image}) =>
z.object({
title: z.string().nonempty().max(100),
exampleImage: image(),
classes: z.optional(z.array(z.string().nonempty()).min(1)),
dataSources: z.array(z.string().nonempty()).min(1),
method: z.string().nonempty(),
quality: z.string().nonempty(),
qualityImage: z.optional(image()),
properties: z.object({
crs: z.string().nonempty(),
time: z.string().nonempty(),
spatialResolution: z.string().nonempty(),
spatialValidity: z.string().nonempty(),
}),
}),
});
const scroller = defineCollection({
type: 'data',
schema: ({image}) =>
z.array(
z.object({
id: z.string().nonempty().max(100),
title: z.string().nonempty().max(100),
image: image(),
description: z.object({
de: z.string().nonempty(),
en: z.string().nonempty(),
}),
location: z.object({
center: z.array(z.number().finite()).length(2),
zoom: z.number().finite().positive(),
pitch: z.number().int().positive(),
bearing: z.number().int(),
}),
}),
),
});
// 4. Export a single `collections` object to register your collection(s)
export const collections = {
data,
cookies,
posts,
publications,
references,
scroller,
services,
};