-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsanity.config.ts
51 lines (48 loc) · 1.34 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
import { defineConfig } from "sanity";
import { deskTool } from "sanity/desk";
import { visionTool } from "@sanity/vision";
import { codeInput } from "@sanity/code-input";
import { markdownSchema } from "sanity-plugin-markdown";
import { media } from "sanity-plugin-media";
import schemas from "src/schemas/schema";
import deskStructure from "src/utils/deskStructure";
const projectId = process.env.NEXT_PUBLIC_SANITY_PROJECT!;
const dataset = process.env.NEXT_PUBLIC_SANITY_DATASET!;
const singletonTypes = ["homepage", "resume", "portfolio"];
export default defineConfig({
title: "Homebase",
basePath: "/studio",
projectId,
dataset,
plugins: [
deskTool({
structure: deskStructure,
}),
visionTool(),
media(),
markdownSchema(),
codeInput(),
],
schema: {
types: schemas,
},
document: {
newDocumentOptions: (prev, { creationContext }) => {
if (creationContext.type === "global") {
return prev.filter(
(templateItem) => !singletonTypes.includes(templateItem.templateId)
);
}
return prev;
},
actions: (prev, { schemaType }) => {
if (singletonTypes.includes(schemaType)) {
return prev.filter(
({ action }) =>
!(action && ["unpublish", "delete", "duplicate"].includes(action))
);
}
return prev;
},
},
});