Skip to content

Instantly share code, notes, and snippets.

@waspeer
Last active November 5, 2020 19:13
Show Gist options
  • Save waspeer/f831dbb06ea59f8f8ca04575e1962cf3 to your computer and use it in GitHub Desktop.
Save waspeer/f831dbb06ea59f8f8ca04575e1962cf3 to your computer and use it in GitHub Desktop.
import { defineDocument } from 'sanity-typed-queries';
const { section } = defineDocument(
'section',
{
name: {
type: 'string',
title: 'Name',
validation: (Rule) => Rule.required(),
},
pages: {
title: 'Pages',
type: 'array',
of: [{ type: 'reference', to: [{ type: 'page' }] }],
},
},
[page],
);
const { page } = defineDocument(
'page',
{
name: {
type: 'string',
title: 'Name',
validation: (Rule) => Rule.required(),
},
pages: {
title: 'Section',
type: 'reference',
to: [{ type: 'section' }],
},
},
[section],
);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment