-
Notifications
You must be signed in to change notification settings - Fork 28
/
interview.tsx
78 lines (77 loc) 路 1.66 KB
/
interview.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
import * as React from 'react'
import {MdPeople} from 'react-icons/md'
import {defineArrayMember, defineField, defineType} from 'sanity'
export default defineType({
name: 'interview',
title: 'Interview',
type: 'document',
icon: MdPeople,
fields: [
defineField({
name: 'title',
title: 'Title',
type: 'string',
validation: (Rule) => Rule.required(),
}),
defineField({
name: 'description',
title: 'Description',
type: 'markdown',
validation: (Rule) => Rule.max(160),
}),
defineField({
name: 'slug',
title: 'Slug',
type: 'slug',
validation: (Rule) => Rule.required(),
options: {
source: 'title',
maxLength: 96,
},
}),
defineField({
name: 'body',
description: 'Body in MDX',
title: 'Body',
type: 'markdown',
}),
defineField({
name: 'portraits',
title: 'Portraits',
type: 'object',
fields: [
{
name: 'image1',
title: 'Image 1',
type: 'externalImage',
validation: (Rule) => Rule.required(),
},
],
}),
defineField({
name: 'resources',
title: 'Resources',
type: 'array',
of: [
defineArrayMember({
title: 'Video Resource',
type: 'reference',
to: [{type: 'videoResource'}],
}),
],
}),
],
preview: {
select: {
title: 'title',
media: 'portraits.image1.url',
},
prepare(selection) {
const {media, title} = selection
return {
title: title,
media: media && <img src={media} alt={title} />,
}
},
},
})