Skip to content

Commit

Permalink
refactor & update schemas of Sanity CMS
Browse files Browse the repository at this point in the history
  • Loading branch information
bozzhik committed Apr 13, 2024
1 parent ecd1fd2 commit 175d828
Show file tree
Hide file tree
Showing 2 changed files with 43 additions and 17 deletions.
28 changes: 18 additions & 10 deletions sanity/schemaTypes/programs.ts
Original file line number Diff line number Diff line change
@@ -1,45 +1,53 @@
import {Rule, SchemaTypeDefinition} from 'sanity'

const programs: SchemaTypeDefinition = {
name: 'program',
title: 'Program',
name: 'programs',
title: 'Программы',
type: 'document',
fields: [
{
name: 'name',
title: 'Program Name',
title: 'Название программы',
type: 'string',
validation: (rule: Rule) => rule.required(),
},
{
name: 'duration',
title: 'Program Duration',
title: 'Длительность программы',
type: 'string',
},
{
name: 'description',
title: 'Program Description',
title: 'Описание программы',
type: 'text',
},
{
name: 'images',
title: 'Program Images',
title: 'Изображения',
type: 'array',
of: [{type: 'image'}],
of: [{type: 'image', options: {hotspot: true}}],
},
{
name: 'pdf',
title: 'Program PDF',
title: 'PDF файл',
type: 'file',
},
{
name: 'slug',
title: 'Program Slug',
title: 'Ссылка',
type: 'slug',
options: {
source: 'name',
},
validation: (rule: Rule) => rule.required(),
},
],
preview: {
select: {
title: 'name',
media: 'images.0.asset',
},
},
}

export default program
export default programs
32 changes: 25 additions & 7 deletions sanity/schemaTypes/stocks.ts
Original file line number Diff line number Diff line change
@@ -1,17 +1,35 @@
import {SchemaEntityTypes} from './index'
import {Rule, SchemaTypeDefinition} from 'sanity'

const stocks: SchemaEntityTypes = {
const stocks: SchemaTypeDefinition = {
name: 'stocks',
title: 'Stocks',
title: 'Акции',
type: 'document',
fields: [
{
name: 'images',
title: 'Stock Images',
type: 'array',
of: [{type: 'image'}],
name: 'title',
title: 'Заголовок',
type: 'string',
},
{
name: 'caption',
title: 'Подпись',
type: 'string',
},
{
name: 'image',
title: 'Stock Image',
type: 'image',
options: {hotspot: true},
validation: (rule: Rule) => rule.required(),
},
],
preview: {
select: {
title: 'title',
subtitle: 'caption',
media: 'image',
},
},
}

export default stocks

0 comments on commit 175d828

Please sign in to comment.