-
Notifications
You must be signed in to change notification settings - Fork 395
/
author.js
114 lines (112 loc) · 2.25 KB
/
author.js
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
import icon from 'react-icons/lib/md/person'
export default {
name: 'author',
type: 'document',
title: 'Author',
icon,
description: 'This represents an author',
__experimental_search: [{path: 'name', weight: 10}],
preview: {
select: {
title: 'name',
awards: 'awards',
relatedAuthors: 'relatedAuthors',
lastUpdated: '_updatedAt',
media: 'image'
},
prepare({title, media, awards}) {
return {
title: title,
media: media,
subtitle: awards && awards.join(', ')
}
}
},
fields: [
{
name: 'name',
title: 'Name',
type: 'string',
validation: Rule => Rule.required()
},
{
name: 'bestFriend',
title: 'Best friend',
type: 'reference',
to: [{type: 'author'}]
},
{
name: 'role',
title: 'Role',
type: 'string',
options: {
list: [
{value: 'developer', title: 'Developer'},
{value: 'designer', title: 'Designer'},
{value: 'ops', title: 'Operations'}
]
}
},
{
name: 'image',
title: 'Image',
type: 'image',
options: {hotspot: true}
},
{
name: 'awards',
title: 'Awards',
type: 'array',
of: [
{
type: 'string'
}
]
},
{
name: 'favoriteBooks',
title: 'Favorite books',
type: 'array',
of: [
{
type: 'reference',
to: {type: 'book'}
}
]
},
{
name: 'minimalBlock',
title: 'Reset all options',
type: 'array',
of: [
{
type: 'block',
styles: [],
lists: [],
marks: {
decorators: [],
annotations: []
}
}
]
},
{
name: 'specie',
title: 'Specie',
description: 'There are a lot of species. Use this to test reference search performence',
type: 'reference',
to: {type: 'species'}
}
],
initialValue: () => ({
name: 'Foo',
bestFriend: {_type: 'reference', _ref: 'foo-bar'},
image: {
_type: 'image',
asset: {
_ref: 'image-8dcc1391e06e4b4acbdc6bbf2e8c8588d537cbb8-4896x3264-jpg',
_type: 'reference'
}
}
})
}