-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathsanity.config.ts
64 lines (57 loc) · 1.91 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
/**
* This configuration is used to for the Sanity Studio that’s mounted on the `/app/studio/[[...index]]/page.tsx` route
*/
import { visionTool } from '@sanity/vision'
import { defineConfig } from 'sanity'
import { structureTool } from 'sanity/structure'
import { approveDocumentAction, improvedDelete } from './sanity/lib/actions'
import { googleMapsInput } from '@sanity/google-maps-input'
import { orderableDocumentListDeskItem } from '@sanity/orderable-document-list'
// Go to https://www.sanity.io/docs/api-versioning to learn how API versioning works
import { apiVersion, dataset, projectId, authToken, useCdn } from './sanity/env';
import { schema } from './sanity/schema'
export default defineConfig({
basePath: '/studio',
projectId,
dataset,
authToken,
schema,
useCdn: false,
document: {
actions: (prev, context) => {
console.log('context', context);
if (context.schemaType === 'listing') {
const array = prev.map((originalAction) => {
return originalAction.action === 'delete' ? improvedDelete : originalAction;
})
return [...array];
}
if (context.schemaType === 'needsApproval') {
return [...prev, approveDocumentAction];
}
return prev
},
},
plugins: [
structureTool({
structure: (S, context) =>
S.list()
.title('Content')
.items([
orderableDocumentListDeskItem({
type: 'listing', // Replace with your document type
title: 'Reorder Listings',
context,
S,
}),
...S.documentTypeListItems(),
]),
}),
googleMapsInput({
apiKey: process.env.NEXT_PUBLIC_GOOGLE_MAPS_API_KEY as string,
}),
// Vision is a tool that lets you query your content with GROQ in the studio
// https://www.sanity.io/docs/the-vision-plugin
visionTool({ defaultApiVersion: apiVersion }),
],
})