159 lines
4.6 KiB
TypeScript
159 lines
4.6 KiB
TypeScript
import {DocumentTextIcon} from '@sanity/icons'
|
|
import {defineType} from 'sanity'
|
|
|
|
const blogPost = defineType({
|
|
name: 'blogPost',
|
|
title: 'Blog posts',
|
|
type: 'document',
|
|
icon: DocumentTextIcon,
|
|
fields: [
|
|
{
|
|
name: 'title',
|
|
title: 'Title',
|
|
type: 'string',
|
|
validation: (r) => r.required(),
|
|
description:
|
|
"The title of the article. Not only will it be used in the article page and list, but also in social previews and other websites, if you don't want to costumise it.",
|
|
},
|
|
{
|
|
name: 'slug',
|
|
title: 'Slug',
|
|
type: 'slug',
|
|
options: {
|
|
source: 'title',
|
|
maxLength: 96,
|
|
},
|
|
validation: (r) => r.required(),
|
|
description:
|
|
'This will be the URL of this article. E.g. "article-one" will be available at URL "/blog/article-one".',
|
|
},
|
|
{
|
|
name: 'headerImage',
|
|
title: 'Header image',
|
|
type: 'image',
|
|
description:
|
|
'This image will be used as the header image in the article page, on the article list/blog page and also eventually on social previews and other websites.',
|
|
validation: (r) => r.required(),
|
|
},
|
|
{
|
|
name: 'department',
|
|
title: 'Department',
|
|
type: 'string',
|
|
description:
|
|
'The department which this article belongs to. If it belongs to no specific department, please leave this field empty.',
|
|
options: {
|
|
list: [
|
|
{value: 'capital', title: 'Capital'},
|
|
{value: 'labs', title: 'Labs'},
|
|
{value: 'research', title: 'Research'},
|
|
],
|
|
},
|
|
},
|
|
{
|
|
name: 'content',
|
|
title: 'Content',
|
|
type: 'array',
|
|
description: 'The body/content of this article.',
|
|
of: [
|
|
{
|
|
type: 'block',
|
|
},
|
|
{
|
|
type: 'image',
|
|
fields: [
|
|
{
|
|
title: 'Caption',
|
|
name: 'caption',
|
|
type: 'text',
|
|
},
|
|
{
|
|
name: 'undecorated',
|
|
type: 'boolean',
|
|
title: 'Undecorated',
|
|
validation: (r) => r.required(),
|
|
initialValue: false,
|
|
},
|
|
],
|
|
},
|
|
],
|
|
validation: (r) => r.required(),
|
|
},
|
|
{
|
|
name: 'summary',
|
|
title: 'Summary',
|
|
type: 'string',
|
|
validation: (r) => r.required(),
|
|
},
|
|
{
|
|
name: 'readTime',
|
|
title: 'Read time',
|
|
type: 'string',
|
|
description:
|
|
"E.g. '3 min' or '420 seconds'. If you don't specify this, we fall back to calculating it for you.",
|
|
},
|
|
{
|
|
name: 'publishDate',
|
|
title: 'Publish date',
|
|
type: 'date',
|
|
description:
|
|
'Leave this empty if you want to use the current date (of publish). If you use a date in the past, everything will go normal. If you use a date in the future, the article will be hidden until that day, on which it will be published automatically.',
|
|
},
|
|
{
|
|
name: 'metadata',
|
|
title: 'Social media and SEO',
|
|
description:
|
|
'Data about the article for SEO, social media previews, etc. This is very important for reach and brand awareness since it will be the first contact many people will have with our brand and content!',
|
|
type: 'object',
|
|
validation: (r) => r.required(),
|
|
fields: [
|
|
{
|
|
name: 'image',
|
|
title: 'Image',
|
|
type: 'image',
|
|
description: "If you don't specify this, falls back to 'Header image'",
|
|
},
|
|
{
|
|
name: 'title',
|
|
title: 'Title',
|
|
type: 'string',
|
|
description: "If you don't specify this, falls back to article title",
|
|
},
|
|
{
|
|
name: 'description',
|
|
title: 'Description',
|
|
type: 'string',
|
|
description: "If you don't specify this, falls back to article summary",
|
|
},
|
|
{
|
|
name: 'twitterCardType',
|
|
title: 'Twitter card type',
|
|
type: 'string',
|
|
description:
|
|
'See https://developer.twitter.com/en/docs/twitter-for-websites/cards/guides/getting-started for more info.',
|
|
options: {
|
|
list: [
|
|
{value: 'summary', title: 'Summary'},
|
|
{
|
|
value: 'summary_large_image',
|
|
title: 'Summary with large image',
|
|
},
|
|
{value: 'player', title: 'Player'},
|
|
{value: 'app', title: 'App'},
|
|
],
|
|
},
|
|
initialValue: 'summary_large_image',
|
|
validation: (r) => r.required(),
|
|
},
|
|
],
|
|
},
|
|
],
|
|
preview: {
|
|
select: {
|
|
title: 'title',
|
|
media: 'headerImage',
|
|
},
|
|
},
|
|
})
|
|
|
|
export default blogPost
|