generated from Open-Study-College/osc-stack
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsanity.config.ts
80 lines (70 loc) · 2.34 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
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
import { createConfig, isDev } from 'sanity';
import {
SANITY_STUDIO_API_DATASET,
SANITY_STUDIO_API_PROJECT_ID,
LOCKED_DOCUMENT_IDS,
SANITY_API_VERSION
} from '~/studio/constants';
// Plugins
import { deskTool } from 'sanity/desk';
import {
dashboardTool,
sanityTutorialsWidget,
projectUsersWidget,
projectInfoWidget
} from '@sanity/dashboard';
import { visionTool } from '@sanity/vision';
import { media } from 'sanity-plugin-media';
// Components
import { structure, defaultDocumentNode } from '~/studio/structure';
import { schemaTypes } from '~/studio/schema';
// Actions
import { deleteAction } from '~/studio/actions/deleteAction';
import { duplicateAction } from '~/studio/actions/duplicateAction';
import shopifyLink from '~/studio/actions/shopifyLink';
export default createConfig({
name: 'default',
title: 'Shopify - openstudydev',
basePath: '/studio',
projectId: SANITY_STUDIO_API_PROJECT_ID,
dataset: SANITY_STUDIO_API_DATASET,
plugins: [
dashboardTool({
widgets: [sanityTutorialsWidget(), projectInfoWidget(), projectUsersWidget()]
}),
deskTool({
structure,
defaultDocumentNode
}),
media(),
// @ts-ignore - expect it to be empty if we're not on the dev store
isDev ? visionTool({ defaultApiVersion: SANITY_API_VERSION }) : []
],
document: {
newDocumentOptions: (prev) => {
// Hide locked documents from 'create new document' menu
const filteredItems = prev.filter((previousItem) => {
const locked = LOCKED_DOCUMENT_IDS.find((id) => id === previousItem.templateId);
return previousItem.templateId !== locked;
});
return filteredItems;
},
// @ts-ignore -- no defined types
actions: (prev) => {
const resolveActions = prev.map((previousAction) => {
switch (previousAction.action) {
case 'delete':
return deleteAction;
case 'duplicate':
return duplicateAction;
default:
return previousAction;
}
});
return [...resolveActions, shopifyLink];
}
},
schema: {
types: schemaTypes
}
});