Nuxt.js quickstart
Defining a schema
The Sanity Studio can only interact with documents in a dataset for which it has schema types registered in its configuration. It currently has none.

1Create a new document type
Create a new file in your Studio’s schemaTypes
folder called postType.ts
with the code below which contains a set of fields for a new post
document type.
import {defineField, defineType} from 'sanity' export const postType = defineType({ name: 'post', title: 'Post', type: 'document', fields: [ defineField({ name: 'title', type: 'string', validation: (rule) => rule.required(), }), defineField({ name: 'slug', type: 'slug', options: {source: 'title'}, validation: (rule) => rule.required(), }), defineField({ name: 'publishedAt', type: 'datetime', initialValue: () => new Date().toISOString(), validation: (rule) => rule.required(), }), defineField({ name: 'image', type: 'image', }), defineField({ name: 'body', type: 'array', of: [{type: 'block'}], }), ], })
2Register the post schema type to the Studio schema
Now you can import this document type into the schemaTypes
array in the index.ts
file in the same folder.
import {postType} from './postType' export const schemaTypes = [postType]
3Publish your first document
When you save these two files, your Studio should automatically reload and show your first document type. Click the +
symbol at the top left to create and publish a new post
document.
Was this page helpful?