-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsanity.config.ts
138 lines (133 loc) · 3.96 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
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
import { defineConfig } from "sanity";
import { structureTool } from "sanity/structure";
import { visionTool } from "@sanity/vision";
import { schemaTypes } from "@/sanity/schemaTypes";
import { media } from "sanity-plugin-media";
import {
RiBook2Line,
RiBrushLine,
RiCameraLine,
RiContactsBookLine,
RiContactsLine,
RiHome2Line,
RiSettings2Line,
} from "react-icons/ri";
import { RiPagesLine } from "react-icons/ri";
import { presentationTool } from "sanity/presentation";
import { orderableDocumentListDeskItem } from "@sanity/orderable-document-list";
import { colorInput } from "@sanity/color-input";
const projectId = process.env.NEXT_PUBLIC_SANITY_PROJECT_ID || "";
const dataset = process.env.NEXT_PUBLIC_SANITY_DATASET || "production";
// 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", "contact", "bookings", "studio"]);
export const structure = (S: any, context: any) => {
return S.list()
.title("Content")
.items([
orderableDocumentListDeskItem({
type: "page",
title: "Custom Pages",
S,
context,
icon: RiPagesLine,
}),
S.listItem()
.title("Home")
.id("home")
.icon(RiHome2Line)
.child(
S.document().schemaType("home").documentId("home").title("Home")
),
S.listItem()
.title("Contact")
.id("contact")
.icon(RiContactsBookLine)
.child(
S.document()
.schemaType("contact")
.documentId("contact")
.title("Contact")
),
S.listItem()
.title("Studio")
.id("studio")
.icon(RiCameraLine)
.child(
S.document().schemaType("studio").documentId("studio").title("Studio")
),
S.listItem()
.title("Terms and Conditions")
.id("termsAndConditions")
.icon(RiBook2Line)
.child(
S.document()
.schemaType("termsAndConditions")
.documentId("termsAndConditions")
.title("Terms and Conditions")
),
S.divider(),
S.listItem()
.title("Creative Projects")
.icon(RiBrushLine)
.child(S.documentTypeList("creativeProject")),
S.divider(),
S.listItem()
.title("Site Meta")
.id("site-meta")
.icon(RiSettings2Line)
.child(
S.document()
.schemaType("siteMeta")
.documentId("site-meta")
.title("Site Meta")
),
S.listItem()
.title("Bookings")
.id("bookings")
.icon(RiSettings2Line)
.child(
S.document()
.schemaType("bookings")
.documentId("bookings")
.title("Bookings")
),
]);
};
export default defineConfig({
basePath: "/admin",
name: "default",
title: "patch-studio",
projectId: projectId,
scheduledPublishing: {
enabled: false,
},
dataset: dataset,
plugins: [
structureTool({ structure }),
// visionTool(),
colorInput(),
media(),
presentationTool({
previewUrl: {
draftMode: {
enable: "/api/draft-mode/enable",
},
},
}),
],
schema: {
types: schemaTypes, // 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,
},
});