-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsanity.config.js
62 lines (55 loc) · 1.61 KB
/
sanity.config.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
import deskStructure from './deskStructure'
import {defineConfig} from 'sanity'
import {structureTool} from 'sanity/structure'
import {schemaTypes} from './schemas/schemas'
// plugins
import {visionTool} from '@sanity/vision'
import {media, mediaAssetSource} from 'sanity-plugin-media'
// import {codeInput} from '@sanity/code-input'
// import {theme} from 'https://themer.sanity.build/api/hues'
export default defineConfig({
// theme,
name: 'Vellandi_Dev',
title: 'Vellandi',
projectId: 'nkdwfm1n',
dataset: 'production',
plugins: [
structureTool({
structure: deskStructure,
}),
visionTool(),
media(),
],
form: {
// Don't use this plugin when selecting files only (but allow all other enabled asset sources)
file: {
assetSources: (previousAssetSources) => {
return previousAssetSources.filter((assetSource) => assetSource !== mediaAssetSource)
},
},
},
tools: (prev, context) => {
const isAdmin = context.currentUser.roles.find(({name}) => name === 'administrator')
if (isAdmin) {
return prev
}
return prev.filter((tool) => tool.name !== 'vision')
},
schema: {
types: schemaTypes,
},
document: {
newDocumentOptions: (prev, {creationContext}) => {
if (creationContext.type === 'global') {
return prev.filter((templateItem) => templateItem.templateId != 'settings')
}
return prev
},
actions: (prev, {schemaType}) => {
if (schemaType === 'settings') {
return prev.filter(({action}) => !['unpublish', 'delete', 'duplicate'].includes(action))
}
return prev
},
},
})