-
Notifications
You must be signed in to change notification settings - Fork 27
/
Copy pathsanity.config.ts
63 lines (56 loc) · 1.88 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
import { CodeBlockIcon, RobotIcon } from "@sanity/icons";
import { visionTool } from "@sanity/vision";
import { projectId } from "lib/sanity-variables";
import { defineConfig, definePlugin, isDev, WorkspaceOptions } from "sanity";
import { deskTool } from "sanity/desk";
import schemas from "schemas";
import deskStructure, { pages } from "./deskStructure";
const devOnlyPlugins = isDev ? [visionTool()] : [];
const readOnlySchemas = [...pages, "page"] as const;
type ReadOnlySchemas = (typeof readOnlySchemas)[number];
const sharedConfig = definePlugin({
name: "shareConfig",
plugins: [deskTool({ structure: deskStructure }), ...devOnlyPlugins],
schema: { types: schemas },
document: {
actions: (prev, { schemaType }) => {
if (readOnlySchemas.includes(schemaType as ReadOnlySchemas))
prev.filter(
({ action }) =>
isDev && !["unpublish", "delete", "duplicate"].includes(action!)
);
return prev;
},
newDocumentOptions: (prev, { creationContext }) => {
if (creationContext.type !== "global" && isDev) {
return prev;
}
return prev.filter(
(templateItem) =>
!readOnlySchemas.includes(templateItem.templateId as ReadOnlySchemas)
);
},
},
});
const devWorkspace: WorkspaceOptions = {
name: "development-workspace",
title: `Juguetear - Development`,
subtitle: "Development",
icon: CodeBlockIcon,
projectId,
dataset: "development",
basePath: "/studio/development",
plugins: [sharedConfig()],
};
const prodWorkspace: WorkspaceOptions = {
name: "production-workspace",
title: `Juguetear ${isDev ? "- Production" : ""}`,
subtitle: "Production",
icon: RobotIcon,
projectId,
dataset: "production",
basePath: "/studio/production",
plugins: [sharedConfig()],
};
const workspaces = isDev ? [devWorkspace, prodWorkspace] : [prodWorkspace];
export default defineConfig(workspaces);