/** * This config is used to set up Sanity Studio that's mounted on the `/pages/studio/[[...index]].tsx` route */ import { visionTool } from '@sanity/vision' import { apiVersion, dataset, previewSecretId, projectId } from 'lib/sanity.api' import { previewDocumentNode } from 'plugins/previewPane' import { productionUrl } from 'plugins/productionUrl' import { settingsPlugin, settingsStructure } from 'plugins/settings' import { defineConfig } from 'sanity' import { deskTool } from 'sanity/desk' import { media } from 'sanity-plugin-media' // import { theStructure } from './src/structure/deskStructure' // SCHEMAS import authorType from 'schemas/author' import contentHeritage from 'schemas/contentheritage' import contentPage from 'schemas/contentPage/content' import culturalHeritageSection from 'schemas/culturalheritage' import gallery from 'schemas/gallery' import culturalSection from 'schemas/homepagesection/section_cultural' import functionsSection from 'schemas/homepagesection/section_functions' import heroHomepage from 'schemas/homepagesection/section_hero_homepage' import homepageSection from 'schemas/homepagesection/section_homepage' import whatsNewBanner from 'schemas/homepagesection/section_whatsnew_banner' import linkGenerate from 'schemas/linkGenerate' import MapInteractive from 'schemas/map' import pageType from 'schemas/page/page' import pagefaq from 'schemas/page/page_faq' import faqTopic from 'schemas/page/page_faq_topic' import callToAction from 'schemas/pagebuilder/calltoAction' import YouTube from 'schemas/pagebuilder/youtube' import customePage from 'schemas/section_customepages' import sectionstory from 'schemas/section_story' import eventType from 'schemas/event' import eventSection from 'schemas/section_event' import career from 'schemas/career' import careerSection from 'schemas/section_career' import settingsType from 'schemas/settings' import wedding from 'schemas/wedding/wedding' import weddingpost from 'schemas/wedding/weddingpost' import weddingPackage from 'schemas/wedding/weddingPackage' import galleryWedding from 'schemas/galleryWedding' //import postType from 'schemas/post' //import category from 'schemas/category' const title = process.env.NEXT_PUBLIC_SANITY_PROJECT_TITLE || 'GWKBALI.COM' export default defineConfig({ basePath: '/studio', projectId, dataset, title, schema: { // content types types: [ authorType, //postType, pageType, settingsType, eventType, //category, callToAction, YouTube, MapInteractive, homepageSection, heroHomepage, culturalSection, functionsSection, eventSection, gallery, galleryWedding, pagefaq, faqTopic, culturalHeritageSection, contentHeritage, sectionstory, customePage, linkGenerate, contentPage, career, careerSection, wedding, weddingpost, whatsNewBanner, weddingPackage, ], }, plugins: [ deskTool({ structure: settingsStructure(settingsType), defaultDocumentNode: previewDocumentNode({ apiVersion, previewSecretId }), }), // Configures the global "new document" button, and document actions, to suit the Settings document singleton settingsPlugin({ type: settingsType.name }), settingsPlugin({ type: eventSection.name }), settingsPlugin({ type: careerSection.name }), settingsPlugin({ type: whatsNewBanner.name }), // Add the "Open preview" action productionUrl({ apiVersion, previewSecretId, types: [ settingsType.name, pageType.name, homepageSection.name, pagefaq.name, whatsNewBanner.name, ], }), // Add an image asset source for Unsplash //unsplashImageAsset(), // Vision lets you query your content with GROQ in the studio // https://www.sanity.io/docs/the-vision-plugin visionTool({ defaultApiVersion: apiVersion }), media(), // cloudinaryAssetSourcePlugin(), // cloudinarySchemaPlugin(), ], form: { image: { assetSources: (previousAssetSources, context) => { //if (context.currentUser?.roles.includes('cloudinaryAccess')) { if (context.currentUser?.roles.includes(null)) { // appends cloudinary as an asset source return [...previousAssetSources] //return [...previousAssetSources, cloudinaryImageSource] } //if (context.currentUser?.roles.includes('onlyCloudinaryAccess')) { if (context.currentUser?.roles.includes(null)) { // only use clooudinary as an asset source //return [cloudinaryImageSource] } // dont add cloudnary as an asset sources return previousAssetSources }, }, }, })