-
Notifications
You must be signed in to change notification settings - Fork 10
/
Copy pathschema.template
203 lines (196 loc) · 4.68 KB
/
schema.template
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
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
import { defineSchema, defineConfig } from 'tinacms';
const schema = defineSchema({
collections: [
{
name: 'categories',
label: 'Categories',
path: 'content/categories',
format: 'json',
fields: [
{
type: 'string',
label: 'Name',
name: 'name',
required: true,
},
{
type: 'string',
label: 'Emoji',
name: 'emoji',
required: false,
},
{
type: 'image',
label: 'Image',
name: 'image',
required: false,
},
],
},
{
name: 'authors',
label: 'Authors',
path: 'content/authors',
format: 'json',
fields: [
{
type: 'string',
label: 'Name',
name: 'name',
required: true,
},
{
type: 'string',
label: 'URL',
name: 'url',
required: false,
},
{
type: 'image',
label: 'Picture',
name: 'picture',
required: false,
},
],
},
{
label: 'Blog Posts',
name: 'posts',
path: 'content/posts',
format: 'mdx',
fields: [
{
type: 'string',
label: 'Title',
name: 'title',
required: true,
description: 'The post title, under 70 chars',
ui: {
validate: (value) => {
if (value?.length > 70) {
return 'Title cannot be more than 70 characters long';
}
},
},
},
{
type: 'string',
label: 'Description',
name: 'description',
required: true,
description: 'The post description, under 160 chars',
ui: {
validate: (value) => {
if (value?.length > 160) {
return 'Description cannot be more than 160 characters long';
}
},
},
},
{
type: 'boolean',
label: 'Published',
name: 'live',
description: 'Is the post published?',
required: true,
},
{
type: 'datetime',
label: 'Date',
name: 'date',
required: true,
},
{
type: 'reference',
label: 'Category',
name: 'category',
collections: ['categories'],
required: true,
},
{
type: 'reference',
label: 'Author',
name: 'author',
description: 'The author of the post',
collections: ['authors'],
required: true,
},
{
label: 'Tags',
name: 'tags',
type: 'string',
list: true,
},
{
type: 'string',
label: 'Canonical',
name: 'canonical',
required: false,
description:
'Use this if you are republishing content from' +
' another website',
},
{
type: 'image',
label: 'Image',
name: 'image',
required: true,
},
{
type: 'rich-text',
label: 'Blog Post Body',
name: 'content',
isBody: true,
required: true,
templates: [
{
name: 'PageSection',
label: 'Page Section',
fields: [
{
type: 'string',
name: 'heading',
label: 'Heading',
},
{
type: 'string',
name: 'content',
label: 'Content',
ui: {
component: 'textarea',
},
},
],
},
],
},
],
},
],
});
export default schema;
// Your tina config
// ==============
const branch = 'main';
// When working locally, hit our local filesystem.
// On a Vercel deployment, hit the Tina Cloud API
const apiURL =
process.env.NODE_ENV == 'development'
? 'http://localhost:4001/graphql'
: `https://content.tinajs.io/content/${process.env.NEXT_PUBLIC_TINA_CLIENT_ID}/github/${branch}`;
export const tinaConfig = defineConfig({
apiURL,
schema,
cmsCallback: (cms) => {
import('tinacms').then(({ RouteMappingPlugin }) => {
const RouteMapping = new RouteMappingPlugin((collection, document) => {
return undefined;
});
cms.plugins.add(RouteMapping);
});
import('react-tinacms-editor').then((field) => {
cms.plugins.add(field.MarkdownFieldPlugin);
});
return cms;
},
});