import { defineArrayMember, defineField, defineType } from 'sanity'
import { TfiLayoutCtaCenter } from 'react-icons/tfi'
import { reputationBlock } from '../misc/reputation'
import { getBlockText } from '@/sanity/lib/utils'
export default defineType({
name: 'hero.saas',
title: 'Hero (SaaS)',
icon: TfiLayoutCtaCenter,
type: 'object',
groups: [
{ name: 'content', default: true },
{ name: 'asset' },
{ name: 'options' },
],
fields: [
defineField({
name: 'options',
type: 'module-options',
group: 'options',
}),
defineField({
name: 'pretitle',
type: 'string',
group: 'content',
}),
defineField({
name: 'content',
type: 'array',
of: [
{ type: 'block' },
defineArrayMember({
title: 'Code block',
type: 'code',
options: {
withFilename: true,
},
}),
{ type: 'custom-html' },
reputationBlock,
],
group: 'content',
}),
defineField({
name: 'ctas',
title: 'Call-to-actions',
type: 'array',
of: [{ type: 'cta' }],
group: 'content',
}),
defineField({
name: 'assets',
title: 'Assets',
type: 'array',
of: [{ type: 'img' }],
validation: (Rule) => Rule.max(1),
group: 'asset',
}),
defineField({
name: 'assetFaded',
type: 'boolean',
initialValue: true,
group: 'asset',
}),
],
preview: {
select: {
content: 'content',
media: 'assets.0.image',
},
prepare: ({ content, media }) => ({
title: getBlockText(content),
subtitle: 'Hero (SaaS)',
media,
}),
},
})