✨Discover storytelling in the AI age with Pixar's Matthew Luhn at Sanity Connect, May 8th—register now

Hello World

By Katie Kodes

A teeny-tiny 1-document-type schema

schema.js

import createSchema from 'part:@sanity/base/schema-creator';
import schemaTypes from 'all:part:@sanity/base/schema-type';

import page from './page';

export default createSchema({
  name: 'default',
  types: schemaTypes.concat([
    page,
  ]),
});

page.js

export default {
    name: 'page',
    title: 'Page',
    type: 'document',
    icon,
    fields: [
      {
        name: 'template',
        title: 'Template',
        type: 'string',
      },
      {
        name: 'slug',
        title: 'Slug',
        type: 'slug',
        description:
          'If not happy with what the system generated, you can hand-edit it here',
      },
      {
        name: 'message',
        title: 'Message',
        type: 'string',
      },
    ],
    preview: {
      select: {
        slug: 'slug',
        template: 'template',
        message: 'message',
      },
      prepare(selection) {
        const { slug, template, message } = selection;
        return {
          title: `${slug.current} [${template}]`,
          subtitle: message,
        };
      },
    },
  };

Just 2 files to go into your Sanity Studio codebase's `schemas` folder -- not enough to be overwhelmed and wonder what things do!

See the "'Hello World' from scratch" community guide to try it yourself.

Contributor