forked from klalicki/portfolio-builder
-
Notifications
You must be signed in to change notification settings - Fork 0
/
keystatic.config.tsx
169 lines (161 loc) · 4.88 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
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
import {
config,
fields,
collection,
singleton,
type BasicFormField,
BlockWrapper,
} from "@keystatic/core";
import { block, repeating, wrapper } from "@keystatic/core/content-components";
import { Icon } from "@keystar/ui/icon";
import { menuConfig } from "./cms/singletons/menuConfig";
import { generalSettings } from "./cms/singletons/generalSettings";
import { typeOptions } from "./cms/singletons/typeOptions";
import { fonts } from "./cms/singletons/fonts";
import * as customFields from "./cms/fields";
import { standardComponents } from "./cms/components/standardComponents";
import { pageComponents } from "./cms/components/pageComponents";
import { hammerIcon } from "@keystar/ui/icon/icons/hammerIcon";
const customNavField = fields.conditional(
fields.checkbox({
label: "Show Sub-Items in Nav",
description:
"Use this option to show project pages beneath this page in the site navigation",
}),
{
false: customFields.uniquify({ label: "unique" }),
true: fields.array(
fields.object({
title: fields.text({ label: "Nav item label" }),
subItems: fields.relationship({
label: "Nav sub-items",
collection: "portfolioGroups",
}),
}),
{
itemLabel(props) {
return (
props.fields.title.value +
(props.fields.subItems.value
? ` (sub-items: ${props.fields.subItems.value})`
: "")
);
},
},
),
},
);
export default config({
ui: {
brand: {
name: "portfolio-builder v1.0",
mark: () => {
return <Icon src={hammerIcon} />;
},
},
navigation: {
Content: ["pages", "homepage"],
"Layout/Appearance": [
"menu",
"typeOptions",
],
Settings: ["fonts", "general"],
},
},
storage: {
kind: "local",
},
collections: {
pages: collection({
label: "Pages",
slugField: "title",
previewUrl: "/{slug}",
path: "src/content/pages/*",
entryLayout: "content",
columns: ["sortID", "publishStatus"],
format: { contentField: "content" },
schema: {
title: fields.slug({ name: { label: "Title" } }),
hideTitle: fields.checkbox({
label: "Hide Title",
defaultValue: false,
description:
"Remove default title element from this page (make sure to include a Heading 1 near the top of the page for accessibility!)",
}),
sortID: fields.number({
label: "Sort ID",
description:
"this number is used to figure out the order for the site menu",
}),
publishStatus: fields.select({
label: "Published?",
description:
'Published means the page is publicly visible and will appear in the "all" portfolio type. Unpublished means the page is completely hidden. Unlisted means the page will be published, but will not be placed in any menus or portfolios unless specifically selected.',
defaultValue: "published",
options: [
{ label: "Yes", value: "published" },
{ label: "No", value: "unpublished" },
{ label: "Unlisted", value: "unlisted" },
],
}),
customNavigation: customNavField,
content: fields.markdoc({
label: "Content",
components: {
...standardComponents,
...pageComponents,
},
options: {
table: false,
image: {
directory: "src/assets/images/pages",
publicPath: "../../assets/images/pages/",
},
},
}),
},
}),
},
singletons: {
typeOptions: typeOptions,
general: generalSettings,
menu: menuConfig,
fonts: fonts,
homepage: singleton({
label: "Homepage",
entryLayout: "content",
previewUrl: "/",
format: { contentField: "content" },
path: "src/content/homepage/index",
schema: {
title: fields.text({ label: "Page Title" }),
hideTitle: fields.checkbox({
label: "Hide Title",
defaultValue: false,
description:
"Remove default title element from this page (make sure to include a Heading 1 near the top of the page for accessibility!)",
}),
sortID: fields.number({
label: "Sort ID",
description:
"this number is used to figure out the order for the site menu",
}),
customNavigation: customNavField,
content: fields.markdoc({
label: "Content",
components: {
...standardComponents,
...pageComponents,
},
options: {
table: false,
image: {
directory: "src/assets/images/pages",
publicPath: "../../assets/images/pages/",
},
},
}),
},
}),
},
});