-
Notifications
You must be signed in to change notification settings - Fork 6
/
hero-schema.js
99 lines (98 loc) · 2.17 KB
/
hero-schema.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
import {
OITextLeftOverlap,
OITextRightOverlap,
OIImage,
OIText,
OITextBottomOverlap,
OITextTopOverlap,
} from "./icons"
export default {
name: "hero",
title: "Hero",
type: "object",
fields: [
{
name: "blockLayout",
title: "Block Layout",
type: "visualOptions",
options: {
list: {
left: {
name: "Text Left / Image Right",
icon: OITextLeftOverlap,
},
right: {
name: "Text Right / Image Left",
icon: OITextRightOverlap,
default: true,
},
top: {
name: "Text Top / Image Bottom",
icon: OITextTopOverlap,
},
bottom: {
name: "Text Botom / Image Top",
icon: OITextBottomOverlap,
},
notext: {
name: "Image, No Text",
icon: OIImage,
},
noimage: {
name: "Text, No Image",
icon: OIText,
},
},
},
},
{
name: "image",
title: "Image",
type: "image",
},
{
name: "blockContent",
title: "Content",
type: "array",
of: [
{
title: "Block",
type: "block",
styles: [
{ title: "Normal", value: "normal" },
{ title: "H1", value: "h1" },
{ title: "H2", value: "h2" },
{ title: "H3", value: "h3" },
{ title: "H4", value: "h4" },
{ title: "Quote", value: "blockquote" },
],
lists: [{ title: "Bullet", value: "bullet" }],
marks: {},
},
{
type: "actionButton",
},
],
},
],
preview: {
select: {
title: "blockContent",
imageUrl: "image.asset.url",
},
prepare(selection) {
const block = (selection.title || []).find(
block => block._type === "block"
)
return {
title: block.children
? block.children
.filter(child => child._type == "span")
.map(span => span.text)
.join("")
: "Hero",
imageUrl: selection.imageUrl,
}
},
},
}