Sanity code examples definitions

import {defineField, defineType} from 'sanity';

export default defineType({
  name: 'codeExample',
  title: 'Code Examples',
  type: 'document',
  fields: [
    defineField({
      name: 'title',
      title: 'Title',
      type: 'string',
    }),
    defineField({
      name: 'language',
      title: 'Language',
      type: 'reference',
      to: {
        type: 'codeLanguage'
      }
    }),
    defineField({
      name: 'slug',
      title: 'Slug',
      type: 'slug',
      options: {
        source: 'title',
      }
    }),
    defineField({
      name: 'content',
      title: 'Content',
      type: 'code',
    })
  ]
});

This code snippet describes the code example sanity schema definition.

Want to download this example?

$ curl https://jezpoz.dev/code-examples/node/sanity-code-examples-definitions/raw > example.ts