[go: nahoru, domu]

Skip to content
This repository has been archived by the owner on Apr 9, 2024. It is now read-only.

Commit

Permalink
resolve grid GraphQL deploy errors
Browse files Browse the repository at this point in the history
  • Loading branch information
codingChewie committed Mar 6, 2023
1 parent 5714ccc commit fffcced
Show file tree
Hide file tree
Showing 3 changed files with 93 additions and 86 deletions.
2 changes: 2 additions & 0 deletions schemas/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ import moduleCallout from './objects/module/callout'
import moduleCallToAction from './objects/module/callToAction'
import moduleCollection from './objects/module/collection'
import moduleGrid from './objects/module/grid'
import gridItems from './objects/module/gridItems'
import moduleImage from './objects/module/image'
import moduleImageAction from './objects/module/imageCallToAction'
import moduleImages from './objects/module/images'
Expand Down Expand Up @@ -84,6 +85,7 @@ const objects = [
moduleCallToAction,
moduleCollection,
moduleGrid,
gridItems,
moduleImage,
moduleImageAction,
moduleImages,
Expand Down
87 changes: 1 addition & 86 deletions schemas/objects/module/grid.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import {ThLargeIcon} from '@sanity/icons'
import pluralize from 'pluralize-esm'
import {defineField} from 'sanity'
import blocksToText from '../../../utils/blocksToText'

export default defineField({
name: 'module.grid',
Expand All @@ -16,91 +15,7 @@ export default defineField({
type: 'array',
of: [
{
name: 'item',
title: 'Item',
type: 'object',
fields: [
// Title
defineField({
name: 'title',
title: 'Title',
type: 'string',
validation: (Rule) => Rule.required(),
}),
// Image
defineField({
name: 'image',
title: 'Image',
type: 'image',
options: {hotspot: true},
validation: (Rule) => Rule.required(),
}),
// Body
defineField({
name: 'body',
title: 'Body',
type: 'array',
of: [
{
lists: [],
marks: {
annotations: [
// Product
{
name: 'annotationProduct',
type: 'annotationProduct',
},
// Email
{
name: 'annotationLinkEmail',
type: 'annotationLinkEmail',
},
// Internal link
{
name: 'annotationLinkInternal',
type: 'annotationLinkInternal',
},
// URL
{
name: 'annotationLinkExternal',
type: 'annotationLinkExternal',
},
],
decorators: [
{
title: 'Italic',
value: 'em',
},
{
title: 'Strong',
value: 'strong',
},
],
},
// Regular styles
styles: [],
// Paragraphs
type: 'block',
},
],
validation: (Rule) => Rule.required(),
}),
],
preview: {
select: {
body: 'body',
image: 'image',
title: 'title',
},
prepare(selection) {
const {body, image, title} = selection
return {
media: image,
subtitle: body && blocksToText(body),
title,
}
},
},
type: 'gridItems',
},
],
},
Expand Down
90 changes: 90 additions & 0 deletions schemas/objects/module/gridItems.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,90 @@
import {defineField} from 'sanity'
import blocksToText from '../../../utils/blocksToText'

export default defineField({
name: 'gridItems',
title: 'Item',
type: 'object',
fields: [
// Title
defineField({
name: 'title',
title: 'Title',
type: 'string',
validation: (Rule) => Rule.required(),
}),
// Image
defineField({
name: 'image',
title: 'Image',
type: 'image',
options: {hotspot: true},
validation: (Rule) => Rule.required(),
}),
// Body
defineField({
name: 'body',
title: 'Body',
type: 'array',
of: [
{
lists: [],
marks: {
annotations: [
// Product
{
name: 'annotationProduct',
type: 'annotationProduct',
},
// Email
{
name: 'annotationLinkEmail',
type: 'annotationLinkEmail',
},
// Internal link
{
name: 'annotationLinkInternal',
type: 'annotationLinkInternal',
},
// URL
{
name: 'annotationLinkExternal',
type: 'annotationLinkExternal',
},
],
decorators: [
{
title: 'Italic',
value: 'em',
},
{
title: 'Strong',
value: 'strong',
},
],
},
// Regular styles
styles: [],
// Paragraphs
type: 'block',
},
],
validation: (Rule) => Rule.required(),
}),
],
preview: {
select: {
body: 'body',
image: 'image',
title: 'title',
},
prepare(selection) {
const {body, image, title} = selection
return {
media: image,
subtitle: body && blocksToText(body),
title,
}
},
},
})

0 comments on commit fffcced

Please sign in to comment.