Skip to content

Commit 0ad0eac

Browse files
committed
allow vision in prod
1 parent 79c0534 commit 0ad0eac

File tree

1 file changed

+190
-181
lines changed

1 file changed

+190
-181
lines changed

sanity.config.ts

Lines changed: 190 additions & 181 deletions
Original file line numberDiff line numberDiff line change
@@ -18,15 +18,15 @@ import { media } from "sanity-plugin-media";
1818
// https://github.com/sanity-io/document-internationalization
1919

2020
import {
21-
presentationTool,
22-
defineDocuments,
23-
defineLocations,
24-
type DocumentLocation,
21+
presentationTool,
22+
defineDocuments,
23+
defineLocations,
24+
type DocumentLocation,
2525
} from "sanity/presentation";
2626
import {
27-
DocumentTypeListBuilder,
28-
type StructureResolver,
29-
structureTool,
27+
DocumentTypeListBuilder,
28+
type StructureResolver,
29+
structureTool,
3030
} from "sanity/structure";
3131

3232
import { apiVersion, dataset, projectId, studioUrl } from "@/sanity/lib/api";
@@ -59,183 +59,192 @@ import tableSchema, { rowType } from "@/sanity/schemas/custom/table";
5959
import { resolveHref } from "@/sanity/lib/resolveHref";
6060

6161
const homeLocation = {
62-
title: "Home",
63-
href: "/",
62+
title: "Home",
63+
href: "/",
6464
} satisfies DocumentLocation;
6565

6666
export const podcastStructure = (): StructureResolver => {
67-
return (S) => {
68-
return S.list()
69-
.title("Content")
70-
.items([
71-
S.listItem()
72-
.title("Podcasts")
73-
.child(
74-
S.list()
75-
.title("Filters")
76-
.items([
77-
S.listItem()
78-
.title("By Type")
79-
.child(
80-
S.documentTypeList("podcastType")
81-
.title("Podcast by Type")
82-
.child((podcastTypeId) =>
83-
S.documentList()
84-
.title("Podcasts")
85-
.filter(
86-
'_type == "podcast" && $podcastTypeId == podcastType._ref',
87-
)
88-
.params({ podcastTypeId }),
89-
),
90-
),
91-
S.listItem()
92-
.title("Missing Hashnode")
93-
.child(() =>
94-
S.documentList()
95-
.title("Podcasts")
96-
.filter('_type == "podcast" && hashnode == null'),
97-
),
98-
S.listItem()
99-
.title("Missing Dev.to")
100-
.child(() =>
101-
S.documentList()
102-
.title("Podcasts")
103-
.filter('_type == "podcast" && devto == null'),
104-
),
105-
S.listItem()
106-
.title("Missing Season")
107-
.child(() =>
108-
S.documentList()
109-
.title("Podcasts")
110-
.filter('_type == "podcast" && season == null'),
111-
),
112-
S.listItem()
113-
.title("Missing Episode")
114-
.child(() =>
115-
S.documentList()
116-
.title("Podcasts")
117-
.filter('_type == "podcast" && episode == null'),
118-
),
119-
S.listItem()
120-
.title("Missing YouTube")
121-
.child(() =>
122-
S.documentList()
123-
.title("Podcasts")
124-
.filter('_type == "podcast" && youtube == null'),
125-
),
126-
]),
127-
),
128-
...S.documentTypeListItems(),
129-
// .filter(
130-
// (listItem) => !['podcast'].includes(`${listItem.getId()}`)
131-
// ),
132-
]);
133-
};
67+
return (S) => {
68+
return S.list()
69+
.title("Content")
70+
.items([
71+
S.listItem()
72+
.title("Podcasts")
73+
.child(
74+
S.list()
75+
.title("Filters")
76+
.items([
77+
S.listItem()
78+
.title("By Type")
79+
.child(
80+
S.documentTypeList("podcastType")
81+
.title("Podcast by Type")
82+
.child((podcastTypeId) =>
83+
S.documentList()
84+
.title("Podcasts")
85+
.filter(
86+
'_type == "podcast" && $podcastTypeId == podcastType._ref',
87+
)
88+
.params({ podcastTypeId }),
89+
),
90+
),
91+
S.listItem()
92+
.title("Missing Hashnode")
93+
.child(() =>
94+
S.documentList()
95+
.title("Podcasts")
96+
.filter('_type == "podcast" && hashnode == null'),
97+
),
98+
S.listItem()
99+
.title("Missing Dev.to")
100+
.child(() =>
101+
S.documentList()
102+
.title("Podcasts")
103+
.filter('_type == "podcast" && devto == null'),
104+
),
105+
S.listItem()
106+
.title("Missing Season")
107+
.child(() =>
108+
S.documentList()
109+
.title("Podcasts")
110+
.filter('_type == "podcast" && season == null'),
111+
),
112+
S.listItem()
113+
.title("Missing Episode")
114+
.child(() =>
115+
S.documentList()
116+
.title("Podcasts")
117+
.filter('_type == "podcast" && episode == null'),
118+
),
119+
S.listItem()
120+
.title("Missing YouTube")
121+
.child(() =>
122+
S.documentList()
123+
.title("Podcasts")
124+
.filter('_type == "podcast" && youtube == null'),
125+
),
126+
]),
127+
),
128+
...S.documentTypeListItems(),
129+
// .filter(
130+
// (listItem) => !['podcast'].includes(`${listItem.getId()}`)
131+
// ),
132+
]);
133+
};
134134
};
135135
export default defineConfig({
136-
basePath: studioUrl,
137-
projectId,
138-
dataset,
139-
schema: {
140-
types: [
141-
// Portable text block types (table)
142-
tableSchema,
143-
rowType,
144-
// Singletons
145-
settings,
146-
dashboardSettings,
147-
pipelineConfig,
148-
remotionConfig,
149-
contentConfig,
150-
sponsorConfig,
151-
distributionConfig,
152-
gcsConfig,
153-
// Documents
154-
author,
155-
guest,
156-
page,
157-
podcast,
158-
podcastType,
159-
post,
160-
sponsor,
161-
previewSession,
162-
sponsorshipRequest,
163-
contentIdea,
164-
automatedVideo,
165-
sponsorLead,
166-
sponsorPool,
167-
],
168-
},
169-
document: {
170-
actions: (prev, context) => {
171-
if (context.schemaType === 'post' || context.schemaType === 'podcast') {
172-
return [sharePreviewAction, ...prev];
173-
}
174-
return prev;
175-
},
176-
},
177-
plugins: [
178-
presentationTool({
179-
resolve: {
180-
mainDocuments: defineDocuments([
181-
{
182-
route: "/post/:slug",
183-
filter: `_type == "post" && slug.current == $slug`,
184-
},
185-
]),
186-
locations: {
187-
settings: defineLocations({
188-
locations: [homeLocation],
189-
message: "This document is used on all pages",
190-
tone: "caution",
191-
}),
192-
post: defineLocations({
193-
select: {
194-
title: "title",
195-
slug: "slug.current",
196-
},
197-
resolve: (doc) => ({
198-
locations: [
199-
{
200-
title: doc?.title || "Untitled",
201-
// biome-ignore lint/style/noNonNullAssertion: <explanation>
202-
href: resolveHref("post", doc?.slug)!,
203-
},
204-
homeLocation,
205-
],
206-
}),
207-
}),
208-
},
209-
},
210-
previewUrl: {
211-
previewMode: {
212-
enable: "/api/draft-mode/enable",
213-
disable: "/api/draft-mode/disable",
214-
},
215-
},
216-
}),
217-
structureTool({ structure: podcastStructure() }),
218-
// Configures the global "new document" button, and document actions, to suit the Settings document singleton
219-
singletonPlugin([settings.name, dashboardSettings.name, pipelineConfig.name, remotionConfig.name, contentConfig.name, sponsorConfig.name, distributionConfig.name, gcsConfig.name]),
220-
// Sets up AI Assist with preset prompts
221-
// https://www.sanity.io/docs/ai-assistPcli
222-
assistWithPresets(),
223-
media(),
224-
// table(), // enable when @sanity/table is installed
225-
// tags(),
226-
codeInput(),
227-
// iconPicker(),
228-
podcastRss({
229-
podcasts: [
230-
{
231-
title: "CodingCat.dev",
232-
url: "https://anchor.fm/s/115b203c/podcast/rss",
233-
},
234-
],
235-
}),
236-
// Vision lets you query your content with GROQ in the studio
237-
// https://www.sanity.io/docs/the-vision-plugin
238-
process.env.NODE_ENV === "development" &&
239-
visionTool({ defaultApiVersion: apiVersion }),
240-
].filter(Boolean) as PluginOptions[],
136+
basePath: studioUrl,
137+
projectId,
138+
dataset,
139+
schema: {
140+
types: [
141+
// Portable text block types (table)
142+
tableSchema,
143+
rowType,
144+
// Singletons
145+
settings,
146+
dashboardSettings,
147+
pipelineConfig,
148+
remotionConfig,
149+
contentConfig,
150+
sponsorConfig,
151+
distributionConfig,
152+
gcsConfig,
153+
// Documents
154+
author,
155+
guest,
156+
page,
157+
podcast,
158+
podcastType,
159+
post,
160+
sponsor,
161+
previewSession,
162+
sponsorshipRequest,
163+
contentIdea,
164+
automatedVideo,
165+
sponsorLead,
166+
sponsorPool,
167+
],
168+
},
169+
document: {
170+
actions: (prev, context) => {
171+
if (context.schemaType === "post" || context.schemaType === "podcast") {
172+
return [sharePreviewAction, ...prev];
173+
}
174+
return prev;
175+
},
176+
},
177+
plugins: [
178+
presentationTool({
179+
resolve: {
180+
mainDocuments: defineDocuments([
181+
{
182+
route: "/post/:slug",
183+
filter: `_type == "post" && slug.current == $slug`,
184+
},
185+
]),
186+
locations: {
187+
settings: defineLocations({
188+
locations: [homeLocation],
189+
message: "This document is used on all pages",
190+
tone: "caution",
191+
}),
192+
post: defineLocations({
193+
select: {
194+
title: "title",
195+
slug: "slug.current",
196+
},
197+
resolve: (doc) => ({
198+
locations: [
199+
{
200+
title: doc?.title || "Untitled",
201+
// biome-ignore lint/style/noNonNullAssertion: <explanation>
202+
href: resolveHref("post", doc?.slug)!,
203+
},
204+
homeLocation,
205+
],
206+
}),
207+
}),
208+
},
209+
},
210+
previewUrl: {
211+
previewMode: {
212+
enable: "/api/draft-mode/enable",
213+
disable: "/api/draft-mode/disable",
214+
},
215+
},
216+
}),
217+
structureTool({ structure: podcastStructure() }),
218+
// Configures the global "new document" button, and document actions, to suit the Settings document singleton
219+
singletonPlugin([
220+
settings.name,
221+
dashboardSettings.name,
222+
pipelineConfig.name,
223+
remotionConfig.name,
224+
contentConfig.name,
225+
sponsorConfig.name,
226+
distributionConfig.name,
227+
gcsConfig.name,
228+
]),
229+
// Sets up AI Assist with preset prompts
230+
// https://www.sanity.io/docs/ai-assistPcli
231+
assistWithPresets(),
232+
media(),
233+
// table(), // enable when @sanity/table is installed
234+
// tags(),
235+
codeInput(),
236+
// iconPicker(),
237+
podcastRss({
238+
podcasts: [
239+
{
240+
title: "CodingCat.dev",
241+
url: "https://anchor.fm/s/115b203c/podcast/rss",
242+
},
243+
],
244+
}),
245+
// Vision lets you query your content with GROQ in the studio
246+
// https://www.sanity.io/docs/the-vision-plugin
247+
// process.env.NODE_ENV === "development" &&
248+
visionTool({ defaultApiVersion: apiVersion }),
249+
].filter(Boolean) as PluginOptions[],
241250
});

0 commit comments

Comments
 (0)