-
Notifications
You must be signed in to change notification settings - Fork 34
/
Copy pathsanity.config.ts
166 lines (164 loc) · 5.4 KB
/
sanity.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
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
// © 2024 Vlad-Stefan Harbuz <[email protected]>
// SPDX-License-Identifier: Apache-2.0
import { defineConfig, defineField } from "sanity";
import { structureTool } from "sanity/structure";
export default defineConfig({
projectId: '4jfayhvz',
dataset: 'production',
plugins: [structureTool()],
schema: {
types: [
{
name: 'author',
title: 'Author',
type: 'document',
fields: [
defineField({
name: 'name',
title: 'Name',
description: 'The name of this author',
type: 'string',
validation: (rule) => rule.required(),
}),
defineField({
name: 'slug',
title: 'Slug',
description: 'The URL part that identifies this author, such as vlad-stefan-harbuz',
type: 'slug',
options: {
source: 'name',
slugify: input => input
.toLowerCase()
.replace(/\s+/g, '-')
.slice(0, 200)
},
validation: (rule) => rule.required(),
}),
defineField({
name: 'avatar',
title: 'Avatar',
description: "The author's avatar image",
type: 'image',
validation: (rule) => rule.required(),
}),
],
},
{
name: 'article',
title: 'Article',
type: 'document',
fields: [
defineField({
name: 'title',
title: 'Title',
description: 'The title of this article',
type: 'string',
validation: (rule) => rule.required(),
}),
defineField({
name: 'slug',
title: 'Slug',
description: 'The URL part that identifies this article, such as my-cool-article',
type: 'slug',
options: {
source: 'title',
slugify: input => input
.toLowerCase()
.replace(/\s+/g, '-')
.slice(0, 200)
},
validation: (rule) => rule.required(),
}),
defineField({
name: 'author',
title: 'Author',
description: 'The author of this article',
type: 'reference',
to: [ { type: 'author' } ],
validation: (rule) => rule.required(),
}),
defineField({
name: 'canonicalUrl',
title: 'Canonical URL',
description: 'If this article has originally been published elsewhere, and that original location should be the canonical URL, enter that original URL here',
type: 'url',
}),
defineField({
name: 'bannerImage',
title: 'Banner Image',
description: 'A banner to be shown at the top of the article',
type: 'image',
}),
defineField({
name: 'bannerImageAltText',
title: 'Banner Image Alt Text',
description: 'Alt text for the banner image',
type: 'string',
}),
defineField({
name: 'publishDateTime',
title: 'Publish Date/Time',
description: 'The UTC date/time at which the article was published. It will not appear on the website before this date/time',
type: 'datetime',
options: {
dateFormat: 'DD MMM YYYY',
},
validation: (rule) => rule.required(),
}),
defineField({
title: 'Content',
name: 'content',
description: "The article's content",
type: 'array',
of: [
{ type: 'block' },
{
type: 'image',
title: 'Captioned Image',
name: 'captionedImage',
fields: [
{
type: 'string',
name: 'altText',
title: 'Image Alt Text',
description: 'A description of the image for accessibility purposes',
},
{
type: 'string',
name: 'caption',
title: 'Image Caption',
description: 'Optional text to show under the image',
},
{
type: 'string',
name: 'titleText',
title: 'Image Title (Hover) Text',
description: 'Optional text that is shown when hoving over the image',
},
{
type: 'url',
name: 'url',
title: 'Image Link URL',
description: 'An optional link, shown in the caption; so a caption is required if you specify a link',
},
{
type: 'string',
name: 'maxWidth',
title: 'Image Max Width',
description: 'An optional max width for the image, as a CSS value (eg 10rem)',
},
]
}
],
validation: (rule) => rule.required(),
})
],
}
],
},
// Sanity's scheduled publishing is a bit cumbersome to work with, so we just
// use our own publishDateTime field.
scheduledPublishing: {
enabled: false,
}
});