-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsanity.config.js
More file actions
86 lines (80 loc) · 2.47 KB
/
sanity.config.js
File metadata and controls
86 lines (80 loc) · 2.47 KB
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
import { defineConfig } from "sanity"
import { deskTool } from 'sanity/desk'
import { visionTool } from '@sanity/vision'
import schemas from './schemas/schema'
import deskStructure from './deskStructure'
import { Logo } from './plugins/logo/Logo'
import { media, mediaAssetSource } from 'sanity-plugin-media'
import { vercelDeployTool } from 'sanity-plugin-vercel-deploy'
import { customTheme } from './utils/theme'
import { defaultDocumentNode } from './utils/defaultDocumentNode'
const singletonActions = new Set(["publish", "discardChanges", "restore"])
const singletonTypes = new Set(["home", "about", "credits", "info", "contact", "privacy"])
export default defineConfig({
title: "Pocket Pieces",
projectId: "u1c1jefd",
dataset: "production",
theme: customTheme,
plugins: [
deskTool({
defaultDocumentNode,
structure: deskStructure
}),
visionTool(),
media(),
vercelDeployTool()
],
form: {
// Don't use this plugin when selecting files only (but allow all other enabled asset sources)
image: {
assetSources: () => [mediaAssetSource]
},
file: {
assetSources: previousAssetSources => {
return previousAssetSources.filter(assetSource => assetSource !== mediaAssetSource)
}
}
},
tools: (prev) => {
if (import.meta.env.DEV) {
return prev
}
return prev.filter((tool) => tool.name !== 'vision')
},
schema: {
types: schemas,
templates: (templates) =>
templates.filter(({ schemaType }) => !singletonTypes.has(schemaType)),
},
studio: {
components: {
logo: Logo
}
},
document: {
productionUrl: async (prev, context) => {
const { dataset, document} = context
if (document._type === 'home') {
const params = new URLSearchParams()
params.set('preview', 'true')
params.set('slug', '/')
return `http://localhost:3000/${params}`
} else {
const params = new URLSearchParams()
params.set('preview', 'true')
params.set('slug', document._type)
return `http://localhost:3000/${params}`
}
},
newDocumentOptions: (prev, { creationContext }) => {
if (creationContext.type === 'global') {
return prev.filter((templateItem) => templateItem.templateId != 'settings')
}
return prev
},
actions: (input, context) =>
singletonTypes.has(context.schemaType)
? input.filter(({ action }) => action && singletonActions.has(action))
: input,
},
});