Error when creating new document type in Desk tool
5 replies
Last updated: May 26, 2022
B
The Desk tool crashed
An uncaught exception in the Desk tool caused the Studio to crash.I just created a new document type, and the studio loads until I try to create a document, when I get the error above.
Code inside thread (to follow)
May 26, 2022, 10:18 PM
B
import { PackageIcon } from '@sanity/icons' import pluralize from 'pluralize' export default { name: 'commonDescription', title: 'Common Description', type: 'document', icon: PackageIcon, fields: [ // Title { name: 'title', title: 'Title', type: 'string', validation: Rule => Rule.required() }, // Description { name: 'description', title: 'Description', type: 'block' }, //Size Chart { name: 'sizeChart', title: 'Size Chart', type: 'block' }, ], preview: { select: { title: 'title' }, prepare(selection) { const { title } = selection return { title } } } }
May 26, 2022, 10:19 PM
B
I’ve added the block documents, imported them all in the schema.js…what am I missing?
May 26, 2022, 10:20 PM
B
here is what the blocks documents look like (I copied them from the “body” block, maybe that’s a problem?)
export default { name: 'description', title: 'Description', type: 'array', of: [ { lists: [ { title: 'Bullet', value: 'bullet' }, { title: 'Numbered', value: 'number' } ], marks: { annotations: [ // Product { name: 'annotationProduct', type: 'annotationProduct' }, // Email { name: 'annotationLinkEmail', type: 'annotationLinkEmail' }, // Internal link { name: 'annotationLinkInternal', type: 'annotationLinkInternal' }, // URL { name: 'annotationLinkExternal', type: 'annotationLinkExternal' } ], decorators: [ { title: 'Italic', value: 'em' }, { title: 'Strong', value: 'strong' } ] }, // Inline blocks of: [{ type: 'blockInlineProduct' }, { type: 'blockInlineProductMarginalia' }], styles: [ { title: 'Heading', value: 'h2' }, { title: 'Quote', value: 'blockquote' } ], type: 'block' }, // Custom blocks { name: 'blockImage', type: 'blockImage' }, { name: 'blockProduct', type: 'blockProduct' } ] }
May 26, 2022, 10:21 PM
The
blocktype needs to be inside an array. Can you comment out
descriptionand
sizeChartto confirm the crash goes away?
May 26, 2022, 10:24 PM
B
perfect, I fixed it now. Thanks again!
May 26, 2022, 10:29 PM
Sanity– build remarkable experiences at scale
Sanity is a modern headless CMS that treats content as data to power your digital business. Free to get started, and pay-as-you-go on all plans.