64 lines
1.4 KiB
TypeScript
64 lines
1.4 KiB
TypeScript
import { format, parseISO } from 'date-fns'
|
|
// import { TiPuzzleOutline } from 'react-icons/ti'
|
|
import { IoDocumentOutline } from 'react-icons/io5'
|
|
import { defineField, defineType } from 'sanity'
|
|
|
|
export default defineType({
|
|
name: 'whatsNewBanner',
|
|
title: 'Whats New Banner',
|
|
icon: IoDocumentOutline,
|
|
type: 'document',
|
|
|
|
fields: [
|
|
defineField({
|
|
name: 'title',
|
|
title: 'Section Name',
|
|
description: 'Nama section di halaman homepage',
|
|
type: 'string',
|
|
// validation: Rule => Rule.required().min(10).max(80)
|
|
}),
|
|
|
|
defineField({
|
|
name: 'mainimage',
|
|
title: 'Image',
|
|
type: 'image',
|
|
description: 'Gambar banner untuk section ini',
|
|
options: {
|
|
hotspot: true,
|
|
},
|
|
fields: [
|
|
{
|
|
title: 'Alternative Text',
|
|
name: 'alt',
|
|
type: 'string',
|
|
},
|
|
],
|
|
}),
|
|
|
|
defineField({
|
|
// set this to hidden
|
|
name: 'date',
|
|
title: 'Date',
|
|
type: 'datetime',
|
|
initialValue: () => new Date().toISOString(),
|
|
}),
|
|
],
|
|
|
|
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(' ') }
|
|
},
|
|
},
|
|
})
|