Desk tool crashing when converting schema to Sanity V3, solved by removing empty "media" tag.
7 replies
Last updated: Feb 12, 2023
B
Hi there! I'm converting our current V2 Studio to Sanity V3. Everything is working great, except with one specific schema (our post schema) the desk tool is crashing and I have no idea why. The debugging message is not helpful; seems to be something with vite?• it works in our V2 studio, but not in V3
â—¦ Am currently setting up the V3 studio into it's own repo from our monorepo so I'm able to see both.
• Nothing has changed in terms of content, I've copied all of the schema files over and viewing all other content in the studio works great except this one.
• Specific error screenshot in thread.
Edit:
✅ Solved! Solution: Make sure your
â—¦ Am currently setting up the V3 studio into it's own repo from our monorepo so I'm able to see both.
• Nothing has changed in terms of content, I've copied all of the schema files over and viewing all other content in the studio works great except this one.
• Specific error screenshot in thread.
Edit:
✅ Solved! Solution: Make sure your
mediaproperties in preview
preparefunctions aren't empty. Used to fly in V2, no longer in V3.
Jan 30, 2023, 10:43 PM
B
Hi RD!
export default { name: 'post', title: 'Post', type: 'document', groups: [ { name: 'main', title: 'Main', default: true, }, { name: 'seo', title: 'SEO', }, ], fields: [ { name: 'meta', title: 'Meta infomation', type: 'metaObject', group: 'seo', }, { name: 'title', title: 'Title', type: 'string', validation: (Rule) => Rule.required(), group: 'main', }, { name: 'slug', title: 'Slug', type: 'slug', options: { source: 'title', maxLength: 96, }, description: 'Click generate to auto-generate a slug based on the title. Slug is used for the URL of the page. Once a slug is created it should not be modified. In the event a slug must be modified, a task will need to be created for the fronted team to put in a redirect.', validation: (Rule) => Rule.required(), group: 'main', }, { name: 'publishedAt', title: 'Published at', type: 'datetime', validation: (Rule) => Rule.required(), group: 'main', }, // { // name: 'author', // title: 'Author', // type: 'reference', // to: { type: 'author' }, // }, { name: 'useYtThumbnail', title: 'Use YouTube Thumbnail as Post Thumbnail', type: 'boolean', description: 'If toggled on, the thumbnail from the Youtube video will be used as the main image for the post.', group: 'main', initialValue: false, }, { name: 'mainImage', title: 'Post Thumbnail', description: 'This image will be used as the thumbnail for the post on the blog index.', type: 'image', group: 'main', hidden: ({ document }) => document.useYtThumbnail, }, { name: 'categories', title: 'Categories', type: 'array', of: [{ type: 'reference', to: { type: 'category' } }], group: 'main', }, { name: 'excerpt', title: 'Excerpt', type: 'text', description: 'The text that will be displayed on the blog listings page. If no description is set, the first 120 characters of the body will be used.', group: 'main', rows: 3, }, { name: 'body', title: 'Body', type: 'blockContent', group: 'main', }, ], preview: { select: { title: 'title', author: 'author.name', }, prepare({ title, subtitle }) { return { title: title, subtitle: subtitle, media: '', } }, }, }
Jan 30, 2023, 10:45 PM
B
Ope I think I just solved it -
user M
deleting the empty "media" tag did the trick! I JUST noticed that, hahaha thank you.Jan 30, 2023, 10:47 PM
Oh great! Was just about to spin up a version of this 🙂 Glad you got it sorted!
Jan 30, 2023, 10:47 PM
B
Thank you!!
Jan 30, 2023, 10:48 PM
A
I got exactly the same
user E
, you are sure that you have renamed the doc schemas from .js to .jsx? (which I hadn’t) because it works fine with media: ''
Feb 12, 2023, 11:32 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.