-
Notifications
You must be signed in to change notification settings - Fork 0
/
keystatic.config.tsx
134 lines (130 loc) · 6.14 KB
/
keystatic.config.tsx
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
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
import {config, fields, collection} from '@keystatic/core';
export default config({
storage: {
kind: 'cloud',
},
cloud: {
project: 'hapmap/hapmap',
},
ui: {
brand: {name: 'HapMap'},
},
collections: {
recipes: collection({
path: 'src/content/recipes/*',
label: 'Recepten',
slugField: 'title',
format: {contentField: 'content'},
columns: ['title', 'created_at', 'category'],
schema: {
title: fields.slug({
name: {label: 'Titel', description: 'De titel van het recept', validation: {isRequired: true}},
slug: {
label: 'Slug',
description: 'De slug van het recept (wordt gebruikt in de url) en autmatisch gegenereerd op basis van de titel'
}
}),
image: fields.image({label: 'Foto'}),
category: fields.select({
label: 'Categorie',
options: [{label: 'Hoofdgerechten', value: 'Hoofdgerechten'}],
defaultValue: 'Hoofdgerechten',
}),
notes: fields.array(
fields.object({
type: fields.select({
label: 'Type',
options: [
{label: 'Tip', value: 'tip'},
{label: 'Warning', value: 'warning'},
{label: 'Info', value: 'info'},
],
defaultValue: 'info',
}),
content: fields.text({label: 'Content'}),
}, {label: 'Note'}),
{label: 'Notities', description: 'Dit zijn notities die bij het recept horen', itemLabel: (props) => (props.fields.type.value + ': ' + props.fields.content.value)}
),
time_minutes: fields.integer({label: 'Time in minutes'}),
created_at: fields.datetime({
label: 'Aangemaakt op',
validation: {isRequired: true},
defaultValue: {kind: 'now'}
}),
ingredients: fields.array(
fields.object({
ingredient: fields.relationship({label: 'Ingredient', collection: 'ingredients'}),
amount: fields.number({label: 'Amount', validation: {isRequired: false}}),
unit: fields.relationship({label: 'Unit', collection: 'units', validation: {isRequired: false}}),
alt_ingredients: fields.array(
fields.object({
for_allergy: fields.relationship({label: 'For allergy', collection: 'allergies'}),
ingredient: fields.relationship({label: 'Ingredient', collection: 'ingredients'}),
amount: fields.number({label: 'Amount', validation: {isRequired: true}}),
unit: fields.relationship({label: 'Unit', collection: 'units'}),
})
, {
label: 'Alternative ingredient',
description: 'Dit kan gebruikt worden om een alternatief ingredient op te geven',
itemLabel: (props) => `${props.fields.ingredient.value} - ${props.fields.amount.value} ${props.fields.unit.value}`
}),
}, {label: 'Ingredient'})
, {
label: 'Ingredienten',
description: 'De ingredienten van het recept, de hoeveelheden zijn per persoon de site rekent dit om naar het aantal personen dat je opgeeft',
itemLabel: (props) => `${props.fields.ingredient.value} - ${props.fields.amount.value} ${props.fields.unit.value}`
}),
content: fields.markdoc({label: 'Het recept', description: 'De inhoud van het recept'}),
},
}),
ingredients: collection({
path: 'src/content/ingredients/*',
label: 'Ingredienten',
slugField: 'name',
format: {data: 'json'},
schema: {
name: fields.slug({
name: {
label: 'Name',
description: 'Dit is de naam van het ingredient in enkelvoud',
validation: {isRequired: true},
},
}),
multiple_name: fields.text({label: 'Meervoud naam'}),
allergies: fields.array(fields.relationship({
label: 'Allergies',
collection: 'allergies'
}), {label: 'Bevat allergieën', itemLabel: (props) => props.value ? props.value : ''}),
alt_for: fields.relationship({label: 'Alt for', collection: 'allergies'}),
},
}),
units: collection({
path: 'src/content/units/*',
label: 'Units',
slugField: 'base_name',
format: {data: 'json'},
schema: {
milli_unit: fields.text({label: 'Milli unit'}),
base_name: fields.text({label: 'Base name', validation: {isRequired: true}}),
kilo_unit: fields.text({label: 'Kilo unit'}),
tone_unit: fields.text({label: 'Tone unit'}),
},
}),
allergies: collection({
path: 'src/content/allergies/*',
slugField: 'name',
label: 'Allergenen',
format: {data: 'json'},
schema: {
name: fields.slug({
name: {
label: 'Name',
description: 'Dit is de naam van het allergie',
validation: {isRequired: true},
},
}),
alt_name: fields.text({label: 'Alt name', validation: {isRequired: true}}),
},
}),
},
});