diff --git a/studioShared/studioConfig.tsx b/studioShared/studioConfig.tsx index 856fb4947..e9a0e713c 100644 --- a/studioShared/studioConfig.tsx +++ b/studioShared/studioConfig.tsx @@ -1,8 +1,14 @@ -import { dataset, projectId } from "./env"; -import { schema } from "./schema"; -import { structureTool } from "sanity/structure"; import { WorkspaceOptions } from "sanity"; import StudioIcon from "../studio/components/studioIcon/StudioIcon"; +import { defineField } from "sanity"; +import { documentInternationalization } from "@sanity/document-internationalization"; +import { visionTool } from "@sanity/vision"; +import { structureTool } from "sanity/structure"; +import { apiVersion, dataset, projectId } from "./env"; +import { schema } from "./schema"; +import { i18n } from "languages"; +import { customerCaseID } from "./schemas/documents/customerCase"; +import { deskStructure } from "./deskStructure"; const config: WorkspaceOptions = { name: "sharedStudio", @@ -12,8 +18,32 @@ const config: WorkspaceOptions = { basePath: "/shared", projectId, dataset, - schema, - plugins: [structureTool()], + schema: { + ...schema, + templates: (prev) => + prev.filter((template) => template.value.language === i18n.base), + }, + plugins: [ + structureTool({ + structure: deskStructure, + }), + visionTool({ defaultApiVersion: apiVersion }), + documentInternationalization({ + // TODO: a function that takes the client and returns a promise of an array of supported languages + // MUST return an "id" and "title" as strings + // supportedLanguages: (client) => client.fetch(`*[_type == "language"]{id, title}`), + supportedLanguages: i18n.languages, + schemaTypes: [customerCaseID], + languageField: `language`, + metadataFields: [defineField({ name: "slug", type: "slug" })], + apiVersion, + // TODO: + // Optional + // Adds UI for publishing all translations at once. Requires access to the Scheduling API + // https://www.sanity.io/docs/scheduling-api + // bulkPublish: true, + }), + ], }; export default config;