From 8d69b3c4885c931771049d456b39b94e32cc353e Mon Sep 17 00:00:00 2001 From: Dean Date: Thu, 23 Jan 2025 15:27:10 -0800 Subject: [PATCH] init sanity --- schemaTypes/articleType.ts | 92 ++++++++++++++++++++++++++++++++++++++ schemaTypes/index.ts | 4 +- 2 files changed, 95 insertions(+), 1 deletion(-) create mode 100644 schemaTypes/articleType.ts diff --git a/schemaTypes/articleType.ts b/schemaTypes/articleType.ts new file mode 100644 index 0000000..9479fbf --- /dev/null +++ b/schemaTypes/articleType.ts @@ -0,0 +1,92 @@ +import { defineField, defineType } from 'sanity' + +export const articleType = defineType({ + name: 'article', + title: 'Article', + type: 'document', + fields: [ + defineField({ + name: 'title', + type: 'string', + title: 'Title', + description: 'The title of the article', + }), + defineField({ + name: 'slug', + type: 'slug', + title: 'Slug', + options: { + source: 'title', + maxLength: 96, + }, + }), + defineField({ + name: 'excerpt', + type: 'text', + title: 'Excerpt', + description: 'A short summary of the article', + }), + defineField({ + name: 'content', + type: 'array', + title: 'Content', + of: [ + { + type: 'block', + styles: [ + { title: 'Normal', value: 'normal' }, + { title: 'Heading 1', value: 'h1' }, + { title: 'Heading 2', value: 'h2' }, + { title: 'Quote', value: 'blockquote' }, + ], + lists: [ + { title: 'Bullet', value: 'bullet' }, + { title: 'Numbered', value: 'number' }, + ], + marks: { + decorators: [ + { title: 'Bold', value: 'strong' }, + { title: 'Italic', value: 'em' }, + ], + annotations: [ + { + name: 'link', + type: 'object', + title: 'Link', + fields: [ + { + name: 'href', + type: 'url', + title: 'URL', + }, + ], + }, + ], + }, + }, + { + type: 'image', + options: { + hotspot: true, + }, + fields: [ + { + name: 'alt', + type: 'string', + title: 'Alternative Text', + description: 'Description of the image for accessibility purposes', + }, + ], + }, + ], + }), + defineField({ + name: 'image', + type: 'image', + title: 'Main Image', + options: { + hotspot: true, + }, + }), + ], +}) diff --git a/schemaTypes/index.ts b/schemaTypes/index.ts index ba4681d..beaffe5 100644 --- a/schemaTypes/index.ts +++ b/schemaTypes/index.ts @@ -1 +1,3 @@ -export const schemaTypes = [] +import {articleType} from './articleType' + +export const schemaTypes = [articleType] \ No newline at end of file