-
Notifications
You must be signed in to change notification settings - Fork 0
/
sanity.config.ts
57 lines (51 loc) · 2.57 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
/**
* 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 { simplerColorInput } from 'sanity-plugin-simpler-color-input'
import { deskTool } from 'sanity/desk'
import { pageStructure, singletonPlugin } from './sanity/plugins/settings'
// Go to https://www.sanity.io/docs/api-versioning to learn how API versioning works
import { theme as sanityTheme } from 'https://themer.sanity.build/api/hues?primary=0026f5&positive=00cc00;400&caution=ffee0d;300'
import { apiVersion, dataset, projectId } from './sanity/env'
import { schema } from './sanity/schema'
import bio from './sanity/schemas/singletons/bio'
import contact from './sanity/schemas/singletons/contact'
import home from './sanity/schemas/singletons/home'
import settings from './sanity/schemas/singletons/settings'
import theme from './sanity/schemas/singletons/theme'
export const PREVIEWABLE_DOCUMENT_TYPES: string[] = []
const title = process.env.NEXT_PUBLIC_SANITY_PROJECT_TITLE || 'Sam Keogh'
// Define the actions that should be available for singleton documents
const singletonActions = new Set(['publish', 'discardChanges', 'restore'])
// Define the singleton document types
const singletonTypes = new Set(['home', 'settings', 'theme', 'bio'])
export default defineConfig({
theme: sanityTheme,
basePath: '/studio',
projectId: projectId,
dataset: dataset,
title: title,
// Add and edit the content schema in the './sanity/schema' folder
schema: {
types: schema.types,
templates: (templates) => templates.filter(({ schemaType }) => !singletonTypes.has(schemaType))
},
plugins: [
deskTool({
structure: pageStructure([home, bio, theme, settings, contact])
}),
// Configures the global "new document" button, and document actions, to suit the Settings document singleton
singletonPlugin(['home', 'bio', 'artist', 'category', 'settings', 'theme', 'contact']),
// 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 }),
simplerColorInput()
],
document: {
// For singleton types, filter out actions that are not explicitly included
// in the `singletonActions` list defined above
actions: (input, context) => (singletonTypes.has(context.schemaType) ? input.filter(({ action }) => action && singletonActions.has(action)) : input)
}
})