-
Notifications
You must be signed in to change notification settings - Fork 0
/
sanity-structure.js
38 lines (33 loc) · 1.11 KB
/
sanity-structure.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
import S from "@sanity/desk-tool/structure-builder";
import IframePreview from './preview/IFramePreview'
import {
FiHome,
FiCamera,
} from 'react-icons/fi'
import { getGlobalSlug, previewURL } from './utils/resolveProductionUrl'
export const getDefaultDocumentNode = ({ schemaType }) => S.document().views(getPreview(schemaType))
const getPreview = (schemaType) => {
const globalSlug = getGlobalSlug(schemaType)
if (globalSlug) {
return [
S.view.form(),
S.view
.component(IframePreview)
.title('Web preview')
.options({ previewURL, isMobile: false, globalSlug }),
S.view
.component(IframePreview)
.title('Mobile preview')
.options({ previewURL, isMobile: true, globalSlug })
]
}
return [S.view.form()]
}
export default () =>
S.list()
.title("Content")
.items([
S.listItem().title('Home').child(S.editor().id('home').schemaType('home').documentId('singleton-home').views(getPreview('home'))).icon(FiHome),
S.divider(),
S.listItem().title('Work').child(S.documentTypeList('work').title('Work')).icon(FiCamera),
]);