| "use client"; |
| |
| |
| |
| import { visionTool } from "@sanity/vision"; |
| import { PluginOptions, defineConfig } from "sanity"; |
| import { unsplashImageAsset } from "sanity-plugin-asset-source-unsplash"; |
| import { |
| presentationTool, |
| defineDocuments, |
| defineLocations, |
| type DocumentLocation, |
| } from "sanity/presentation"; |
| import { structureTool } from "sanity/structure"; |
|
|
| import { apiVersion, dataset, projectId, studioUrl } from "@/sanity/lib/api"; |
| import { pageStructure, singletonPlugin } from "@/sanity/plugins/settings"; |
| import { assistWithPresets } from "@/sanity/plugins/assist"; |
| import author from "@/sanity/schemas/documents/author"; |
| import post from "@/sanity/schemas/documents/post"; |
| import settings from "@/sanity/schemas/singletons/settings"; |
| import { resolveHref } from "@/sanity/lib/utils"; |
|
|
| const homeLocation = { |
| title: "Home", |
| href: "/", |
| } satisfies DocumentLocation; |
|
|
| export default defineConfig({ |
| basePath: studioUrl, |
| projectId, |
| dataset, |
| schema: { |
| types: [ |
| |
| settings, |
| |
| post, |
| author, |
| ], |
| }, |
| plugins: [ |
| presentationTool({ |
| resolve: { |
| mainDocuments: defineDocuments([ |
| { |
| route: "/posts/:slug", |
| filter: `_type == "post" && slug.current == $slug`, |
| }, |
| ]), |
| locations: { |
| settings: defineLocations({ |
| locations: [homeLocation], |
| message: "This document is used on all pages", |
| tone: "caution", |
| }), |
| post: defineLocations({ |
| select: { |
| title: "title", |
| slug: "slug.current", |
| }, |
| resolve: (doc) => ({ |
| locations: [ |
| { |
| title: doc?.title || "Untitled", |
| href: resolveHref("post", doc?.slug)!, |
| }, |
| homeLocation, |
| ], |
| }), |
| }), |
| }, |
| }, |
| previewUrl: { previewMode: { enable: "/api/draft-mode/enable" } }, |
| }), |
| structureTool({ structure: pageStructure([settings]) }), |
| |
| singletonPlugin([settings.name]), |
| |
| unsplashImageAsset(), |
| |
| |
| assistWithPresets(), |
| |
| |
| process.env.NODE_ENV === "development" && |
| visionTool({ defaultApiVersion: apiVersion }), |
| ].filter(Boolean) as PluginOptions[], |
| }); |
|
|