// studio / schemas / documents / review.js import {format} from 'date-fns' export default { name: 'review', type: 'document', title: 'Reviews', fields: [ { name: 'title', type: 'string', title: 'Title', description: 'Titles should be catchy, descriptive, and not too long' }, { name: 'slug', type: 'slug', title: 'Slug', description: 'Some frontends will require a slug to be set to be able to show the post', options: { source: 'title', maxLength: 96 } }, { name: 'publishedAt', type: 'datetime', title: 'Published at', description: 'This can be used to schedule post for publishing' }, { name: 'mainImage', type: 'mainImage', title: 'Main image' }, { name: 'excerpt', type: 'excerptPortableText', title: 'Excerpt', description: 'This ends up on summary pages, on Google, when people share your post in social media.' }, { name: 'authors', title: 'Authors', type: 'array', of: [ { type: 'authorReference' } ] }, { title: 'Tag', name: 'tag', type: 'array', of: [{type: 'string'}], options: { layout: 'tags' } }, { name: 'categories', type: 'array', title: 'Review Category', of: [ { type: 'reference', to: [ { title: 'Category', type: 'categoryReview' } ] } ] }, { name: 'reviews', type: 'array', title: 'Collection of Reviews', of: [ { type: 'reviewText' } ] } ], orderings: [ { name: 'publishingDateAsc', title: 'Publishing date new–>old', by: [ { field: 'publishedAt', direction: 'asc' }, { field: 'title', direction: 'asc' } ] }, { name: 'publishingDateDesc', title: 'Publishing date old->new', by: [ { field: 'publishedAt', direction: 'desc' }, { field: 'title', direction: 'asc' } ] } ], preview: { select: { title: 'title', publishedAt: 'publishedAt', slug: 'slug', media: 'mainImage' }, prepare({ title = 'No title', publishedAt, slug = {}, media }) { const path = `/${slug.current}/` return { title, media, subtitle: publishedAt ? path : 'Missing publishing date' } } } }