Something went wrong. Try again.
[READ-ONLY] Mirror of https://github.com/danielroe/roe.dev. This is the code and content for my personal website, built in Nuxt. roe.dev
Something went wrong. Try again.
2.9 kB · 117 lines
TypeScript
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118import { defineField, defineType } from 'sanity'
export default defineType({ name: 'uses', title: 'Uses', type: 'document', fields: [ defineField({ name: 'category', title: 'Category', type: 'string', validation: Rule => Rule.required(), }), defineField({ name: 'order', title: 'Order', type: 'number', description: 'Used to control the order of categories', initialValue: 100, }), defineField({ name: 'displayAsGrid', title: 'Display as Grid', type: 'boolean', description: 'Display items in a grid layout instead of a list', initialValue: false, }), defineField({ name: 'items', title: 'Items', type: 'array', of: [ { type: 'object', name: 'item', fields: [ defineField({ name: 'name', title: 'Name', type: 'string', validation: Rule => Rule.required(), }), defineField({ name: 'description', title: 'Description', type: 'text', }), defineField({ name: 'links', title: 'Links', type: 'array', of: [ { type: 'object', name: 'link', fields: [ defineField({ name: 'url', title: 'URL', type: 'url', validation: Rule => Rule.required(), }), defineField({ name: 'label', title: 'Label', type: 'string', }), ], preview: { select: { title: 'label', subtitle: 'url', }, }, }, ], }), defineField({ name: 'image', title: 'Image', type: 'image', options: { hotspot: true, }, }), defineField({ name: 'order', title: 'Order', type: 'number', description: 'Used to control the order of items within a category', initialValue: 100, }), ], preview: { select: { title: 'name', subtitle: 'description', media: 'image', }, }, }, ], }), ], preview: { select: { title: 'category', subtitle: 'order', }, prepare ({ title, subtitle }) { return { title, subtitle: `Order: ${subtitle}`, } }, },})