-
Notifications
You must be signed in to change notification settings - Fork 1
/
keystatic.config.tsx
152 lines (150 loc) Β· 4.45 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
// keystatic.config.ts
import { config, fields, collection, component, singleton } from '@keystatic/core';
import { block, wrapper } from '@keystatic/core/content-components'
import VideoPlayer from '@components/VideoPlayer';
import { Clapperboard, FileWarning } from 'lucide-react';
export default config({
ui: {
brand: {
name: 'Armno.in.th'
}
},
storage: {
kind: 'local',
},
collections: {
posts: collection({
entryLayout: 'content',
label: 'Posts',
slugField: 'title',
path: 'src/content/blog/*/',
format: { contentField: 'content' },
schema: {
title: fields.slug({ name: { label: 'Title' } }),
pubDate: fields.datetime({
label: 'Publish Date (UTC)',
defaultValue: {
kind: 'now'
}
}),
description: fields.text({ label: 'Description' }),
language: fields.select({
label: 'Language',
defaultValue: 'en',
options: [
{ label: 'English', value: 'en', },
{ label: 'Thai', value: 'th', }
]
}),
tags: fields.array(
fields.text({ label: 'Tag' }),
{
label: 'Tags',
itemLabel: props => props.value
}
),
thumbnail: fields.image({
label: 'Thumbnail',
directory: 'public/images',
publicPath: '/images',
}),
content: fields.markdoc({
label: 'Content',
options: {
image: {
directory: 'src/content/blog/',
publicPath: '../../../content/blog/',
}
},
components: {
warningMessage: wrapper({
label: 'Warning Message',
description: 'Display a warning message',
icon: <FileWarning />,
schema: {
title: fields.text({
label: 'Title'
}),
},
}),
video: block({
label: 'Video',
description: 'Upload a video',
icon: <Clapperboard />,
ContentView: (props) => {
const { src, ...otherProps} = props.value;
if (!src) {
return <></>;
}
const blob = new Blob([src.data], { type: 'video/mp4' });
const url = URL.createObjectURL(blob);
return (
<VideoPlayer src={url} {...otherProps} />
)
},
schema: {
src: fields.file({
label: 'Video file',
description: 'Select a video file',
directory: 'public/videos/',
publicPath: '/videos/',
}),
controls: fields.checkbox({
label: 'Controls',
description: 'Show video controls',
defaultValue: false
}),
autoPlay: fields.checkbox({
label: 'Autoplay',
description: 'Enable autoplay (will mute the video)',
defaultValue: false
}),
loop: fields.checkbox({
label: 'Loop',
description: 'Enable looping',
defaultValue: false
})
},
})
}
})
},
}),
},
singletons: {
uses: singleton({
entryLayout: 'content',
label: 'Uses',
path: 'src/pages/uses/',
format: { contentField: 'content' },
schema: {
title: fields.text({ label: 'Title' }),
description: fields.text({ label: 'Description' }),
pubDate: fields.text({ label: 'Publish Date' }),
layout: fields.text({ label: 'Layout' }),
language: fields.select({
label: 'Language',
defaultValue: 'en',
options: [
{ label: 'English', value: 'en', },
{ label: 'Thai', value: 'th', }
]
}),
thumbnail: fields.image({
label: 'Thumbnail',
directory: 'public/images/uses/content',
publicPath: '/images/uses/content',
}),
content: fields.mdx({
label: 'Content',
options:{
image: {
directory: 'src/pages/uses/content/',
publicPath: '../../pages/uses/content/',
}
}
}),
}
})
}
});