-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathkeystatic.config.ts
More file actions
180 lines (176 loc) · 5.02 KB
/
Copy pathkeystatic.config.ts
File metadata and controls
180 lines (176 loc) · 5.02 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
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
170
171
172
173
174
175
176
177
178
179
180
import { collection, config, fields } from '@keystatic/core'
import { BrandMark } from './src/keystatic/BrandMark'
// Side-effect: inject site-matched Admin skin as soon as the client bundle loads.
import './src/keystatic/ensure-theme'
/**
* Content CMS for blogs + leetcode Markdown under src/content/*.
*
* Storage:
* - local → `pnpm dev` (writes files on disk)
* - github → Netlify production (commits via GitHub App; only repo writers)
*
* Draft workflow (GitHub mode, see src/keystatic/draft-workflow.ts):
* - Auto-save: browser IndexedDB only (Keystatic built-in)
* - Save: forced onto branch `keystatic/drafts` (not main)
* - Publish: banner button → main + delete draft
*
* Override: KEYSTATIC_STORAGE=local|github
*
* Reason: Admin UI runs in the browser. `process.env` is empty in the client
* bundle, so storage mode is inlined at build time via Vite define
* (`__KEYSTATIC_USE_GITHUB__` from astro.config.mjs). Without that, production
* incorrectly used local mode → `/api/keystatic/tree` 404 → "Not Found" JSON error.
*/
declare const __KEYSTATIC_USE_GITHUB__: boolean
const useGithub = __KEYSTATIC_USE_GITHUB__
export default config({
storage: useGithub
? {
kind: 'github',
// Must match the GitHub repo connected to Netlify
repo: 'priority3/priority.me',
}
: {
kind: 'local',
},
ui: {
brand: {
name: 'priority.me',
mark: BrandMark,
},
navigation: {
Content: ['blogs', '---', 'leetcode'],
},
},
collections: {
blogs: collection({
label: 'Blogs',
slugField: 'title',
path: 'src/content/blogs/*',
format: { contentField: 'content' },
entryLayout: 'content',
// Collection list columns (besides Name) — dates read as mono meta in Admin skin
columns: ['date', 'author', 'display'],
schema: {
title: fields.slug({
name: {
label: 'Title',
validation: { isRequired: true },
},
}),
author: fields.text({
label: 'Author',
defaultValue: 'priority',
}),
date: fields.date({
label: 'Date',
validation: { isRequired: true },
}),
desc: fields.text({
label: 'Description',
multiline: true,
}),
subtitle: fields.text({
label: 'Subtitle',
}),
language: fields.text({
label: 'Language',
description: 'e.g. CN, EN, EN/CN',
}),
display: fields.checkbox({
label: 'Display on site',
defaultValue: true,
}),
content: fields.markdoc({
label: 'Content',
// Existing posts are .md (not default .mdoc)
extension: 'md',
options: {
heading: [1, 2, 3, 4],
bold: true,
italic: true,
strikethrough: true,
code: true,
codeBlock: true,
divider: true,
link: true,
table: true,
blockquote: true,
orderedList: true,
unorderedList: true,
image: {
directory: 'public/images/blogs',
publicPath: '/images/blogs/',
},
},
}),
},
}),
leetcode: collection({
label: 'Leetcode',
slugField: 'title',
path: 'src/content/leetcode/*',
format: { contentField: 'content' },
entryLayout: 'content',
columns: ['date', 'tag', 'display'],
schema: {
title: fields.slug({
name: {
label: 'Title',
validation: { isRequired: true },
},
}),
author: fields.text({
label: 'Author',
defaultValue: 'priority',
}),
date: fields.date({
label: 'Date',
validation: { isRequired: true },
}),
desc: fields.text({
label: 'Description',
multiline: true,
}),
language: fields.text({
label: 'Language',
description: 'e.g. CN, EN, EN/CN',
}),
display: fields.checkbox({
label: 'Display on site',
defaultValue: true,
}),
tag: fields.select({
label: 'Tag',
options: [
{ label: 'leetcode', value: 'leetcode' },
{ label: 'typehero', value: 'typehero' },
],
defaultValue: 'leetcode',
}),
content: fields.markdoc({
label: 'Content',
extension: 'md',
options: {
heading: [1, 2, 3, 4],
bold: true,
italic: true,
strikethrough: true,
code: true,
codeBlock: true,
divider: true,
link: true,
table: true,
blockquote: true,
orderedList: true,
unorderedList: true,
image: {
directory: 'public/images/leetcode',
publicPath: '/images/leetcode/',
},
},
}),
},
}),
},
})