-
Notifications
You must be signed in to change notification settings - Fork 12
/
sanity.config.ts
64 lines (59 loc) · 1.85 KB
/
sanity.config.ts
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
import deskStructure from '@/lib/deskStructure';
import CMYKParticipationDatatable from '@/plugins/cmyk-participation-datatable';
import schemas from '@/schemas';
import { colorInput } from '@sanity/color-input';
import { dashboardTool } from '@sanity/dashboard';
import { visionTool } from '@sanity/vision';
import { WorkspaceOptions, defineConfig, definePlugin, isDev } from 'sanity';
import { deskTool } from 'sanity/desk';
import { projectId } from './sanity.env';
const devOnlyPlugins = isDev ? [visionTool()] : [];
const sharedConfig = definePlugin({
name: 'shareConfig',
plugins: [
deskTool({ structure: deskStructure }),
colorInput(),
dashboardTool({ widgets: [CMYKParticipationDatatable] }),
...devOnlyPlugins,
],
schema: { types: schemas },
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;
},
},
});
const devWorkspace: WorkspaceOptions = {
name: 'development-workspace',
title: `FEC - Development`,
subtitle: 'Development',
projectId,
dataset: 'develop',
basePath: '/studio/development',
plugins: [sharedConfig()],
};
const prodWorkspace: WorkspaceOptions = {
name: 'production-workspace',
title: `FEC ${isDev ? '- Production' : ''}`,
subtitle: 'Production',
projectId,
dataset: 'production',
basePath: '/studio/production',
plugins: [sharedConfig()],
};
const workspaces = isDev ? [devWorkspace, prodWorkspace] : [prodWorkspace];
export default defineConfig(workspaces);