-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathkeystatic.config.ts
87 lines (85 loc) · 2.5 KB
/
keystatic.config.ts
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
import { config, fields, singleton } from "@keystatic/core";
import { getCollection } from "astro:content";
import React from "react";
const teas = await getCollection("teas");
const possibleBases = [
...teas[0].data
.map((tea) => tea.base)
.reduce((set, base) => set.add(base), new Set()),
];
const possibleTags = [
...teas[0].data
.flatMap((tea) => tea.tags)
.reduce((set, value) => set.add(value), new Set()),
];
export default config({
storage: import.meta.env.PUBLIC_KEYSTATIC_GITHUB_APP_SLUG
? {
kind: "github",
repo: {
owner: "TODO",
name: "TODO",
},
}
: { kind: "local" },
ui: {
brand: {
name: "My Tea Menu",
mark: () =>
React.createElement("img", { src: "/favicon-32x32.png", height: 24 }),
},
},
singletons: {
teas: singleton({
label: "Teas",
path: "src/content/teas/teas",
schema: {
teas: fields.array(
fields.object({
name: fields.text({ label: "Name" }),
tags: fields.array(
fields.text({
label: "Tag",
description: `e.g. ${possibleTags.join(", ")}`,
}),
{ label: "Tags", itemLabel: (props) => props.value },
),
ingredients: fields.array(fields.text({ label: "Ingredient" }), {
label: "Ingredients",
itemLabel: (props) => props.value,
}),
muchCaffeine: fields.checkbox({ label: "Much caffeine?" }),
type: fields.select({
label: "Type of tea",
options: [
{ label: "Bagged", value: "bag" },
{ label: "Loose-leaf", value: "loose" },
],
defaultValue: "bag",
}),
base: fields.text({
label: "Base",
description: `e.g. ${possibleBases.join(", ")}`,
}),
inStock: fields.checkbox({
label: "In stock?",
defaultValue: true,
}),
brewTemp: fields.integer({ label: "Brew temperature (°C)" }),
brewTime: fields.text({
label: "Brew time",
description: "e.g. 3--5 minutes",
}),
whereFrom: fields.text({
label: "Where did it come from?",
description: "e.g. Twinings",
}),
}),
{
itemLabel: (props) => props.fields.name.value,
},
),
},
}),
},
});