import { format, parseISO } from 'date-fns' import { IoDocumentOutline } from 'react-icons/io5' import { defineField, defineType } from 'sanity' //pagebuilder schema import authorType from '../author' export default defineType({ name: 'heroHomepage', title: 'Hero Section', icon: IoDocumentOutline, type: 'document', fields: [ defineField({ name: 'title', title: 'Section Name', type: 'string', description: 'Nama section di halaman homepage', }), defineField({ name: 'video', title: 'Video URL', type: 'string', description: 'URL background di section Hero pada Home', }), defineField({ name: 'videomobile', title: 'Video URL (mobile version)', type: 'string', description: 'URL background di section Hero pada Home (Mobile version)', }), // defineField({ // name: 'video', // title: 'Video', // type: 'file', // description: 'Video background di section Hero pada Home', // }), defineField({ // set this to hidden name: 'date', title: 'Date', type: 'datetime', initialValue: () => new Date().toISOString(), }), defineField({ name: 'author', title: 'Author', type: 'reference', to: [{ type: authorType.name }], }), ], preview: { select: { title: 'title', author: 'author.name', date: 'date', media: 'coverImage', }, prepare({ title, media, author, date }) { const subtitles = [ author && `by ${author}`, date && `on ${format(parseISO(date), 'LLL d, yyyy')}`, ].filter(Boolean) return { title, media, subtitle: subtitles.join(' ') } }, }, })