import { FiUser } from 'react-icons/fi'
import { createHeading, formatDate } from '../../helpers'
import SlugInput from 'sanity-plugin-better-slug'
import { isUniqueAcrossAllDocuments } from '../functions/isUniqueAcrossAllDocuments'
export default {
name: 'author',
title: 'Author',
type: 'document',
icon: FiUser,
fields: [
{
name: 'name',
title: 'Name',
type: 'string'
},
{
name: 'slug',
title: 'Slug',
type: 'slug',
inputComponent: SlugInput,
validation: (Rule) => Rule.required(),
options: {
source: 'name',
maxLength: 100,
basePath: '<http://localhost.com|localhost.com>',
isUnique: isUniqueAcrossAllDocuments,
slugify: (input) =>
input.toLowerCase().replace(/\s+/g, '-').slice(0, 100)
}
},
{
title: 'Job title',
name: 'jobTitle',
type: 'string',
validation: (Rule) =>
Rule.required().error('This is required dear friend!'),
options: {
list: [
// Others
{ title: 'Managing Partner', value: 'Managing Partner' },
{ title: 'Account Director', value: 'Account Director' },
{ title: 'Creative Director', value: 'Creative Director' },
{ title: 'Concepter', value: 'Concepter' },
{ title: 'Finance', value: 'Finance' },
{ title: 'Producer', value: 'Producer' },
{ title: 'Storyteller', value: 'Storyteller' },
// Developers
{ title: 'Lead Developer', value: 'Lead Developer' },
{ title: 'Senior Developer', value: 'Senior Developer' },
{ title: 'Medior Developer', value: 'Medior Developer' },
{ title: 'Junior Developer', value: 'Junior Developer' },
// Designers
{ title: 'Lead Designer', value: 'Lead Designer' },
{ title: 'Senior Designer', value: 'Senior Designer' },
{ title: 'Medior Designer', value: 'Medior Designer' },
{ title: 'Junior Designer', value: 'Junior Designer' },
{ title: 'Junior Creative', value: 'Junior Creative' }
]
}
},
{
name: 'bio',
title: 'Bio',
type: 'blockContent'
},
{
name: 'authorImage',
title: 'Author image',
type: 'imageWithAltText'
}
],
preview: {
select: {
title: 'name',
jobTitle: 'jobTitle',
media: 'authorImage'
},
prepare(selection) {
const { title, jobTitle } = selection
return Object.assign({}, selection, {
title: title,
subtitle: jobTitle
})
}
}
}