sno-blog/sanity.config.ts
2026-02-02 23:32:03 +03:00

62 lines
1.8 KiB
TypeScript
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

import { defineConfig } from 'sanity'
import { deskTool, type StructureBuilder } from 'sanity/desk'
import { visionTool } from '@sanity/vision'
import { codeInput } from '@sanity/code-input'
import { schemaTypes } from './sanity/schemas'
const projectId = process.env.NEXT_PUBLIC_SANITY_PROJECT_ID!
const dataset = process.env.NEXT_PUBLIC_SANITY_DATASET || 'production'
export default defineConfig({
name: 'so-imit-blog',
title: 'СО ИМИТ ВолГУ - Блог',
projectId,
dataset,
plugins: [
deskTool({
structure: (S: StructureBuilder) =>
S.list()
.title('Контент')
.items([
S.listItem()
.title('Посты')
.icon(() => '📝')
.child(S.documentTypeList('post').title('Посты')),
S.listItem()
.title('События')
.icon(() => '📅')
.child(S.documentTypeList('event').title('События')),
S.divider(),
S.listItem()
.title('Авторы')
.icon(() => '👤')
.child(S.documentTypeList('author').title('Авторы')),
S.listItem()
.title('Категории')
.icon(() => '📁')
.child(S.documentTypeList('category').title('Категории')),
]),
}),
visionTool(),
codeInput(),
],
schema: {
types: schemaTypes,
},
document: {
newDocumentOptions: (prev, { creationContext }) => {
// Filter out certain document types from the "Create new" menu
if (creationContext.type === 'global') {
return prev.filter(
(template) => !['author', 'category'].includes(template.templateId)
)
}
return prev
},
},
})