Issue creating a document in Sanity Studio due to invalid schema
10 replies
Last updated: Feb 27, 2023
K
Hi! When I create a document in sanity studio, I met some issue.
Let me know any hint please.
Thanks for your time.
🎉
This document has the schema type *, which is not defined as a type in the local content studio schema.
Thanks for your time.
🎉
Feb 24, 2023, 1:51 AM
D
Can you paste in your current schema?
Feb 24, 2023, 12:36 PM
K
sure
Feb 24, 2023, 3:17 PM
K
import {DocumentIcon} from '@sanity/icons';
import {validateSlug} from '../../utils/validateSlug';
export default {
name: 'page',
title: 'Page',
type: 'document',
icon: DocumentIcon,
groups: [
{
name: 'theme',
title: 'Theme',
},
{
default: true,
name: 'editorial',
title: 'Editorial',
},
{
name: 'seo',
title: 'SEO',
},
],
fields: [
// Title
{
name: 'title',
title: 'Title',
type: 'string',
validation: (_Rule_) _=>_
_Rule_.required(),
},
// Slug
{
name: 'slug',
type: 'slug',
options: {source: 'title'},
validation: validateSlug,
},
// Color theme
{
name: 'colorTheme',
title: 'Color theme',
type: 'reference',
to: [{type: 'colorTheme'}],
group: 'theme',
},
// Show hero
{
name: 'showHero',
title: 'Show hero',
type: 'boolean',
description: 'If disabled, page title will be displayed instead',
initialValue: false,
group: 'editorial',
},
// Hero
{
name: 'hero',
title: 'Hero',
type: 'hero.page',
hidden: ({_document_}) _=>_ !_document_?.showHero,
group: 'editorial',
},
// Body
{
name: 'body',
title: 'Body',
type: 'body',
group: 'editorial',
},
// SEO
{
name: 'seo',
title: 'SEO',
type: 'seo.page',
group: 'seo',
},
],
preview: {
select: {
active: 'active',
seoImage: 'seo.image',
title: 'title',
},
prepare(_selection_) {
_const_ {seoImage, title} = _selection_;
return {
media: seoImage,
title,
};
},
},
};
Feb 24, 2023, 3:18 PM
D
Did you get to desk tool without problems? And when you encounter the issue only when you click the New button to create a new
pagedocument?
Feb 25, 2023, 12:26 PM
D
It looks to me that the schema is invalid.
Feb 25, 2023, 12:26 PM
K
Let me know in detail.
Feb 26, 2023, 10:37 AM
D
I mean, I tried this and I’m probably missing a few files or I’m just not sure about using
seo.imagefor example whether that’s valid.
Feb 26, 2023, 1:47 PM
D
I think you have the schema there for
seocorrect? can you send it and the others?
Feb 26, 2023, 1:47 PM
K
I don't think it is issue. Would you like to try without that? Otherwise it is related to saved documents? There are 2 page documents already.
Feb 26, 2023, 11:24 PM
D
unfortunately, I can’t replicate your setup to the best of my abilities. with the schema you provided, I can’t run Sanity studio because there were errors
Feb 27, 2023, 1:15 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.