Gwk-Cultural-Park/schemas/wedding/weddingPackage.ts

101 lines
3.1 KiB
TypeScript
Raw Normal View History

2024-09-07 01:40:25 +00:00
// import { BookIcon } from '@sanity/icons'
import { format, parseISO } from 'date-fns'
import { TiCalendarOutline } from 'react-icons/ti'
import { defineField, defineType } from 'sanity'
import authorType from '../author'
export default defineType({
name: 'weddingpackage',
2024-09-16 13:03:05 +00:00
title: 'Wedding Brosur',
2024-09-07 01:40:25 +00:00
icon: TiCalendarOutline,
type: 'document',
fields: [
defineField({
name: 'title',
title: 'Title',
type: 'string',
validation: (rule) => rule.required(),
}),
defineField({
name: 'content',
2024-09-16 13:03:05 +00:00
title: 'Detail paket wedding',
2024-09-07 01:40:25 +00:00
type: 'array',
of: [{
type: 'block',
styles: [
{ title: 'Normal', value: 'normal' },
{ title: 'H1', value: 'h1' },
{ title: 'H2', value: 'h2' },
{ title: 'H3', value: 'h3' },
{ title: 'H4', value: 'h4' },
{ title: 'H5', value: 'h5' },
{ title: 'H6', value: 'h6' },
{ title: 'ul', value: 'ul' },
{ title: 'ol', value: 'ol' },
{ title: 'Quote', value: 'blockquote' },
],
marks: {
decorators: [
{ title: 'Strong', value: 'strong' },
{ title: 'Emphasis', value: 'em' },
],
annotations: [
{
name: 'link',
type: 'object',
title: 'URL',
fields: [
{
title: 'URL',
name: 'href',
type: 'url',
},
],
},
],
},
}],
}),
defineField({
name: 'fileWedding',
2024-09-16 13:03:05 +00:00
title: 'File Brosur',
2024-09-07 01:40:25 +00:00
type: 'file',
options: {
accept: 'application/pdf',
storeOriginalFilename: true
},
validation: (rule) => rule.required()
}),
defineField({
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(' ') }
},
},
})