-
Notifications
You must be signed in to change notification settings - Fork 0
/
sanity.config.ts
60 lines (55 loc) · 1.84 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
/**
* 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 { deskTool } from "sanity/desk";
import { presentationTool } from "sanity/presentation";
import { codeInput } from "@sanity/code-input";
import { locate } from "@/sanity/presentation/locate";
// 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";
// 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(["header"]);
export default defineConfig({
basePath: "/studio",
projectId,
dataset,
schema,
plugins: [
deskTool({
structure: (S) =>
S.list()
.title("Content")
.items([
S.listItem()
.title("Header")
.id("header")
.child(S.document().schemaType("header").documentId("Header")),
S.documentTypeListItem("post").title("Post"),
S.documentTypeListItem("bookmark").title("Bookmark"),
S.documentTypeListItem("project").title("Project"),
S.documentTypeListItem("category").title("Category"),
]),
}),
codeInput(),
visionTool({ defaultApiVersion: apiVersion }),
presentationTool({
locate,
previewUrl: {
draftMode: {
enable: "/api/draft",
},
},
}),
],
document: {
actions: (input, context) =>
singletonTypes.has(context.schemaType)
? input.filter(({ action }) => action && singletonActions.has(action))
: input,
},
});