-
Notifications
You must be signed in to change notification settings - Fork 11
Expand file tree
/
Copy pathsanity.config.ts
More file actions
65 lines (59 loc) · 2.02 KB
/
sanity.config.ts
File metadata and controls
65 lines (59 loc) · 2.02 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
"use client";
/**
* This configuration is used to for the Sanity Studio that’s mounted on the `/app/studio/[[...tool]]/page.tsx` route
*/
import { visionTool } from "@sanity/vision";
import { defineConfig } from "sanity";
import { structureTool } from "sanity/structure";
import { presentationTool } from "sanity/presentation";
// Go to https://www.sanity.io/docs/api-versioning to learn how API versioning works
import { apiVersion, dataset, projectId } from "./sanity/env";
import { schema } from "./sanity/schema";
import { resolve } from "@/sanity/presentation/resolve";
import { structure } from "./sanity/structure";
import { codeInput } from "@sanity/code-input";
// Define the actions that should be available for singleton documents
const singletonActions = new Set([
"publish",
"discardChanges",
"restore",
"unpublish",
]);
// Define the singleton document types
const singletonTypes = new Set(["settings"]);
export default defineConfig({
basePath: "/studio",
title: "Schema UI",
projectId,
dataset,
// Add and edit the content schema in the './sanity/schema' folder
schema: {
types: schema.types,
// Filter out singleton types from the global "New document" menu options
templates: (templates) =>
templates.filter(({ schemaType }) => !singletonTypes.has(schemaType)),
},
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,
},
plugins: [
structureTool({ structure }),
presentationTool({
previewUrl: {
draftMode: {
enable: "/api/draft-mode/enable",
},
},
resolve,
}),
// 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 }),
codeInput(),
],
});