Skip to content

Commit 5a390ad

Browse files
author
Alex Patterson
committed
add podcast group in studio
1 parent 6a9495d commit 5a390ad

1 file changed

Lines changed: 29 additions & 3 deletions

File tree

‎sanity.config.ts‎

Lines changed: 29 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ import {
2222
defineLocations,
2323
type DocumentLocation,
2424
} from "sanity/presentation";
25-
import { structureTool } from "sanity/structure";
25+
import { DocumentTypeListBuilder, StructureResolver, structureTool } from "sanity/structure";
2626

2727
import { apiVersion, dataset, projectId, studioUrl } from "@/sanity/lib/api";
2828
import { pageStructure, singletonPlugin } from "@/sanity/plugins/settings";
@@ -44,6 +44,32 @@ const homeLocation = {
4444
href: "/",
4545
} satisfies DocumentLocation;
4646

47+
export const podcastStructure = (
48+
structure: StructureResolver
49+
): StructureResolver => {
50+
return (S) => {
51+
return S.list()
52+
.title("Content")
53+
.items([
54+
S.listItem()
55+
.title('Podcasts')
56+
.child(
57+
S.documentTypeList('podcastType')
58+
.title('Podcast by Type')
59+
.child((podcastTypeId) =>
60+
S.documentList()
61+
.title('Posts')
62+
.filter('_type == "podcast" && $podcastTypeId == podcastType._ref')
63+
.params({ podcastTypeId })
64+
)
65+
),
66+
...S.documentTypeListItems().filter(
67+
(listItem) => !['podcast'].includes(`${listItem.getId()}`)
68+
),
69+
]);
70+
};
71+
};
72+
4773
export default defineConfig({
4874
basePath: studioUrl,
4975
projectId,
@@ -98,7 +124,7 @@ export default defineConfig({
98124
},
99125
previewUrl: { previewMode: { enable: "/api/draft" } },
100126
}),
101-
structureTool({ structure: pageStructure([settings]) }),
127+
structureTool({ structure: podcastStructure(pageStructure([settings])) }),
102128
// Configures the global "new document" button, and document actions, to suit the Settings document singleton
103129
singletonPlugin([settings.name]),
104130
// Sets up AI Assist with preset prompts
@@ -119,6 +145,6 @@ export default defineConfig({
119145
// Vision lets you query your content with GROQ in the studio
120146
// https://www.sanity.io/docs/the-vision-plugin
121147
process.env.NODE_ENV === "development" &&
122-
visionTool({ defaultApiVersion: apiVersion }),
148+
visionTool({ defaultApiVersion: apiVersion }),
123149
].filter(Boolean) as PluginOptions[],
124150
});

0 commit comments

Comments
 (0)