@sanity/cli 3.36.4 → 3.36.5-canary.34

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (116) hide show
  1. package/lib/_chunks-cjs/cli.js +1779 -1317
  2. package/lib/_chunks-cjs/cli.js.map +1 -1
  3. package/lib/_chunks-cjs/journeyConfig.js +11 -11
  4. package/lib/_chunks-cjs/journeyConfig.js.map +1 -1
  5. package/lib/_chunks-cjs/loadEnv.js +105 -2719
  6. package/lib/_chunks-cjs/loadEnv.js.map +1 -1
  7. package/lib/cli.d.ts +10 -0
  8. package/lib/index.d.ts +448 -0
  9. package/lib/index.esm.js +449 -5
  10. package/lib/index.esm.js.map +1 -1
  11. package/lib/index.js +3 -3
  12. package/lib/index.js.map +1 -1
  13. package/lib/index.mjs +452 -0
  14. package/lib/index.mjs.map +1 -0
  15. package/lib/run.d.ts +1 -0
  16. package/lib/workers/getAndWriteJourneySchema.d.ts +1 -0
  17. package/lib/workers/getCliConfig.d.ts +1 -0
  18. package/lib/workers/typegenGenerate.d.ts +37 -0
  19. package/lib/workers/typegenGenerate.js +6 -2
  20. package/lib/workers/typegenGenerate.js.map +1 -1
  21. package/package.json +18 -21
  22. package/src/actions/init-project/templates/shopify.ts +7 -0
  23. package/src/util/journeyConfig.ts +5 -5
  24. package/templates/ecommerce/plugins/barcode-input/BarcodeInput.js +1 -1
  25. package/templates/get-started/plugins/sanity-plugin-tutorial/GetStartedTutorial.tsx +1 -1
  26. package/templates/shared/tsconfig.json +2 -4
  27. package/templates/shopify/README.md +3 -3
  28. package/templates/shopify/components/hotspots/ProductTooltip.tsx +1 -1
  29. package/templates/shopify/components/icons/Shopify.tsx +1 -1
  30. package/templates/shopify/components/inputs/CollectionHidden.tsx +1 -1
  31. package/templates/shopify/components/media/ColorTheme.tsx +1 -1
  32. package/templates/shopify/components/studio/Navbar.tsx +29 -0
  33. package/templates/shopify/constants.ts +31 -1
  34. package/templates/shopify/docs/features.md +6 -7
  35. package/templates/shopify/schemaTypes/documents/collection.tsx +11 -47
  36. package/templates/shopify/schemaTypes/documents/colorTheme.tsx +2 -17
  37. package/templates/shopify/schemaTypes/documents/page.ts +10 -37
  38. package/templates/shopify/schemaTypes/documents/product.tsx +4 -27
  39. package/templates/shopify/schemaTypes/documents/productVariant.tsx +4 -13
  40. package/templates/shopify/schemaTypes/index.ts +97 -126
  41. package/templates/shopify/schemaTypes/objects/collection/{group.ts → collectionGroupType.ts} +7 -10
  42. package/templates/shopify/schemaTypes/objects/collection/{links.ts → collectionLinksType.ts} +4 -4
  43. package/templates/shopify/schemaTypes/objects/customProductOption/{colorObject.tsx → customProductOptionColorObjectType.tsx} +3 -6
  44. package/templates/shopify/schemaTypes/objects/customProductOption/{color.tsx → customProductOptionColorType.tsx} +2 -10
  45. package/templates/shopify/schemaTypes/objects/customProductOption/{sizeObject.ts → customProductOptionSizeObjectType.ts} +3 -7
  46. package/templates/shopify/schemaTypes/objects/customProductOption/{size.ts → customProductOptionSizeType.ts} +3 -12
  47. package/templates/shopify/schemaTypes/objects/global/footerType.ts +22 -0
  48. package/templates/shopify/schemaTypes/objects/global/menuLinksType.ts +21 -0
  49. package/templates/shopify/schemaTypes/objects/global/{menu.ts → menuType.ts} +2 -4
  50. package/templates/shopify/schemaTypes/objects/global/{notFoundPage.ts → notFoundPageType.ts} +1 -6
  51. package/templates/shopify/schemaTypes/objects/hotspot/{imageWithProductHotspots.ts → imageWithProductHotspotsType.ts} +4 -6
  52. package/templates/shopify/schemaTypes/objects/hotspot/{productHotspots.tsx → productHotspotsType.tsx} +3 -5
  53. package/templates/shopify/schemaTypes/objects/hotspot/{spot.tsx → spotType.tsx} +1 -3
  54. package/templates/shopify/schemaTypes/{annotations/linkEmail.tsx → objects/link/linkEmailType.tsx} +5 -13
  55. package/templates/shopify/schemaTypes/{annotations/linkExternal.tsx → objects/link/linkExternalType.tsx} +6 -13
  56. package/templates/shopify/schemaTypes/{annotations/linkInternal.tsx → objects/link/linkInternalType.tsx} +5 -12
  57. package/templates/shopify/schemaTypes/{annotations/product.tsx → objects/link/linkProductType.tsx} +4 -16
  58. package/templates/shopify/schemaTypes/objects/module/{accordionGroup.ts → accordionGroupType.ts} +6 -9
  59. package/templates/shopify/schemaTypes/objects/module/{accordion.ts → accordionType.ts} +4 -11
  60. package/templates/shopify/schemaTypes/objects/module/{callToAction.tsx → callToActionType.tsx} +10 -23
  61. package/templates/shopify/schemaTypes/objects/module/{callout.ts → calloutType.ts} +4 -10
  62. package/templates/shopify/schemaTypes/objects/module/{collection.tsx → collectionReferenceType.tsx} +4 -9
  63. package/templates/shopify/schemaTypes/objects/module/gridItemType.ts +41 -0
  64. package/templates/shopify/schemaTypes/objects/module/{grid.ts → gridType.ts} +7 -15
  65. package/templates/shopify/schemaTypes/objects/{hero/home.tsx → module/heroType.tsx} +14 -17
  66. package/templates/shopify/schemaTypes/objects/module/{imageCallToAction.tsx → imageCallToActionType.tsx} +6 -10
  67. package/templates/shopify/schemaTypes/objects/module/{image.ts → imageFeatureType.ts} +6 -18
  68. package/templates/shopify/schemaTypes/objects/module/{images.tsx → imageFeaturesType.tsx} +7 -25
  69. package/templates/shopify/schemaTypes/objects/module/{instagram.ts → instagramType.ts} +2 -2
  70. package/templates/shopify/schemaTypes/objects/module/{products.tsx → productFeaturesType.tsx} +6 -11
  71. package/templates/shopify/schemaTypes/objects/module/{product.tsx → productReferenceType.tsx} +6 -8
  72. package/templates/shopify/schemaTypes/objects/{seo/seo.ts → seoType.ts} +7 -6
  73. package/templates/shopify/schemaTypes/objects/shopify/{shopifyCollectionRule.tsx → collectionRuleType.tsx} +2 -10
  74. package/templates/shopify/schemaTypes/objects/shopify/{inventory.ts → inventoryType.ts} +7 -12
  75. package/templates/shopify/schemaTypes/objects/shopify/{option.tsx → optionType.tsx} +6 -12
  76. package/templates/shopify/schemaTypes/objects/shopify/{placeholderString.ts → placeholderStringType.ts} +3 -1
  77. package/templates/shopify/schemaTypes/objects/shopify/{priceRange.ts → priceRangeType.ts} +5 -7
  78. package/templates/shopify/schemaTypes/objects/shopify/{productWithVariant.tsx → productWithVariantType.tsx} +2 -2
  79. package/templates/shopify/schemaTypes/objects/shopify/{proxyString.ts → proxyStringType.ts} +1 -1
  80. package/templates/shopify/schemaTypes/objects/shopify/{shopifyCollection.ts → shopifyCollectionType.ts} +4 -25
  81. package/templates/shopify/schemaTypes/objects/shopify/{shopifyProduct.ts → shopifyProductType.ts} +5 -35
  82. package/templates/shopify/schemaTypes/objects/shopify/{shopifyProductVariant.ts → shopifyProductVariantType.ts} +1 -27
  83. package/templates/shopify/schemaTypes/portableText/portableTextSimpleType.tsx +45 -0
  84. package/templates/shopify/schemaTypes/portableText/portableTextType.tsx +52 -0
  85. package/templates/shopify/schemaTypes/singletons/homeType.ts +49 -0
  86. package/templates/shopify/schemaTypes/singletons/{settings.ts → settingsType.ts} +7 -9
  87. package/templates/shopify/utils/shopifyUrls.ts +3 -3
  88. package/templates/shopify/utils/validateSlug.ts +3 -7
  89. package/lib/_chunks-cjs/index.js +0 -547
  90. package/lib/_chunks-cjs/index.js.map +0 -1
  91. package/lib/_chunks-cjs/node.js +0 -213
  92. package/lib/_chunks-cjs/node.js.map +0 -1
  93. package/lib/_chunks-cjs/stegaEncodeSourceMap.js +0 -357
  94. package/lib/_chunks-cjs/stegaEncodeSourceMap.js.map +0 -1
  95. package/lib/_chunks-es/index.js +0 -3336
  96. package/lib/_chunks-es/index.js.map +0 -1
  97. package/lib/_chunks-es/node.js +0 -216
  98. package/lib/_chunks-es/node.js.map +0 -1
  99. package/lib/_chunks-es/stegaEncodeSourceMap.js +0 -358
  100. package/lib/_chunks-es/stegaEncodeSourceMap.js.map +0 -1
  101. package/lib/index.cjs.mjs +0 -7
  102. package/templates/shopify/schemaTypes/blocks/body.tsx +0 -70
  103. package/templates/shopify/schemaTypes/objects/global/footer.ts +0 -57
  104. package/templates/shopify/schemaTypes/objects/global/linkExternal.ts +0 -52
  105. package/templates/shopify/schemaTypes/objects/global/linkInternal.ts +0 -65
  106. package/templates/shopify/schemaTypes/objects/global/links.ts +0 -16
  107. package/templates/shopify/schemaTypes/objects/hero/collection.tsx +0 -42
  108. package/templates/shopify/schemaTypes/objects/hero/page.tsx +0 -35
  109. package/templates/shopify/schemaTypes/objects/module/accordionBody.ts +0 -45
  110. package/templates/shopify/schemaTypes/objects/module/gridItem.ts +0 -91
  111. package/templates/shopify/schemaTypes/objects/seo/description.tsx +0 -10
  112. package/templates/shopify/schemaTypes/objects/seo/home.tsx +0 -31
  113. package/templates/shopify/schemaTypes/objects/seo/page.tsx +0 -37
  114. package/templates/shopify/schemaTypes/objects/seo/shopify.tsx +0 -40
  115. package/templates/shopify/schemaTypes/singletons/home.ts +0 -62
  116. /package/lib/{dts/src/index.d.ts → index.d.mts} +0 -0
@@ -1,6 +1,6 @@
1
1
  import {defineField} from 'sanity'
2
2
 
3
- export default defineField({
3
+ export const notFoundPageType = defineField({
4
4
  name: 'notFoundPage',
5
5
  title: '404 page',
6
6
  type: 'object',
@@ -8,19 +8,16 @@ export default defineField({
8
8
  fields: [
9
9
  defineField({
10
10
  name: 'title',
11
- title: 'Title',
12
11
  type: 'string',
13
12
  validation: (Rule) => Rule.required(),
14
13
  }),
15
14
  defineField({
16
15
  name: 'body',
17
- title: 'Body',
18
16
  type: 'text',
19
17
  rows: 2,
20
18
  }),
21
19
  defineField({
22
20
  name: 'collection',
23
- title: 'Collection',
24
21
  type: 'reference',
25
22
  description: 'Collection products displayed on this page',
26
23
  weak: true,
@@ -31,10 +28,8 @@ export default defineField({
31
28
  },
32
29
  ],
33
30
  }),
34
- // Color theme
35
31
  defineField({
36
32
  name: 'colorTheme',
37
- title: 'Color theme',
38
33
  type: 'reference',
39
34
  to: [{type: 'colorTheme'}],
40
35
  }),
@@ -2,7 +2,7 @@ import {ImageIcon} from '@sanity/icons'
2
2
  import pluralize from 'pluralize-esm'
3
3
  import {defineField} from 'sanity'
4
4
 
5
- export default defineField({
5
+ export const imageWithProductHotspotsType = defineField({
6
6
  icon: ImageIcon,
7
7
  name: 'imageWithProductHotspots',
8
8
  title: 'Image',
@@ -10,20 +10,19 @@ export default defineField({
10
10
  fields: [
11
11
  defineField({
12
12
  name: 'image',
13
- title: 'Image',
14
13
  options: {hotspot: true},
15
14
  type: 'image',
16
15
  validation: (Rule) => Rule.required(),
16
+ // Hide original image when showHotspots is true and an image is set
17
+ hidden: ({value, parent}) => parent.showHotspots && value,
17
18
  }),
18
19
  defineField({
19
20
  name: 'showHotspots',
20
- title: 'Show product hotspots',
21
21
  type: 'boolean',
22
22
  initialValue: false,
23
23
  }),
24
24
  defineField({
25
25
  name: 'productHotspots',
26
- title: 'Product hotspots',
27
26
  type: 'productHotspots',
28
27
  hidden: ({parent}) => !parent.showHotspots,
29
28
  }),
@@ -35,8 +34,7 @@ export default defineField({
35
34
  image: 'image',
36
35
  showHotspots: 'showHotspots',
37
36
  },
38
- prepare(selection) {
39
- const {fileName, hotspots, image, showHotspots} = selection
37
+ prepare({fileName, hotspots, image, showHotspots}) {
40
38
  return {
41
39
  media: image,
42
40
  subtitle:
@@ -1,15 +1,13 @@
1
- import {defineField} from 'sanity'
1
+ import {defineArrayMember, defineField} from 'sanity'
2
2
 
3
3
  import ProductTooltip from '../../../components/hotspots/ProductTooltip'
4
4
 
5
- export default defineField({
5
+ export const productHotspotsType = defineField({
6
6
  name: 'productHotspots',
7
7
  title: 'Hotspots',
8
8
  type: 'array',
9
9
  of: [
10
- {
11
- type: 'spot',
12
- },
10
+ defineArrayMember({type: 'spot'}),
13
11
  ],
14
12
  options: {
15
13
  imageHotspot: {
@@ -1,9 +1,8 @@
1
- import React from 'react'
2
1
  import {defineField} from 'sanity'
3
2
 
4
3
  import ShopifyDocumentStatus from '../../../components/media/ShopifyDocumentStatus'
5
4
 
6
- export default defineField({
5
+ export const spotType = defineField({
7
6
  name: 'spot',
8
7
  title: 'Spot',
9
8
  type: 'object',
@@ -11,7 +10,6 @@ export default defineField({
11
10
  fields: [
12
11
  defineField({
13
12
  name: 'productWithVariant',
14
- title: 'Product + Variant',
15
13
  type: 'productWithVariant',
16
14
  }),
17
15
  defineField({
@@ -1,15 +1,9 @@
1
- /**
2
- * Annotations are ways of marking up text in the block content editor.
3
- *
4
- * Read more: https://www.sanity.io/docs/customization#f924645007e1
5
- */
6
1
  import {EnvelopeIcon} from '@sanity/icons'
7
- import React from 'react'
8
2
  import {defineField} from 'sanity'
9
3
 
10
- export default defineField({
4
+ export const linkEmailType = defineField({
11
5
  title: 'Email link',
12
- name: 'annotationLinkEmail',
6
+ name: 'linkEmail',
13
7
  type: 'object',
14
8
  icon: EnvelopeIcon,
15
9
  components: {
@@ -27,16 +21,14 @@ export default defineField({
27
21
  ),
28
22
  },
29
23
  fields: [
30
- // Email
31
- {
32
- title: 'Email',
24
+ defineField({
33
25
  name: 'email',
34
26
  type: 'email',
35
- },
27
+ }),
36
28
  ],
37
29
  preview: {
38
30
  select: {
39
- email: 'email',
31
+ title: 'email',
40
32
  },
41
33
  },
42
34
  })
@@ -1,15 +1,9 @@
1
- /**
2
- * Annotations are ways of marking up text in the block content editor.
3
- *
4
- * Read more: https://www.sanity.io/docs/customization#f924645007e1
5
- */
6
1
  import {EarthGlobeIcon} from '@sanity/icons'
7
- import React from 'react'
8
2
  import {defineField} from 'sanity'
9
3
 
10
- export default defineField({
4
+ export const linkExternalType = defineField({
11
5
  title: 'External Link',
12
- name: 'annotationLinkExternal',
6
+ name: 'linkExternal',
13
7
  type: 'object',
14
8
  icon: EarthGlobeIcon,
15
9
  components: {
@@ -27,18 +21,17 @@ export default defineField({
27
21
  ),
28
22
  },
29
23
  fields: [
30
- {
24
+ defineField({
31
25
  name: 'url',
32
26
  title: 'URL',
33
27
  type: 'url',
34
28
  validation: (Rule) => Rule.required().uri({scheme: ['http', 'https']}),
35
- },
36
- // Open in a new window
37
- {
29
+ }),
30
+ defineField({
38
31
  title: 'Open in a new window?',
39
32
  name: 'newWindow',
40
33
  type: 'boolean',
41
34
  initialValue: true,
42
- },
35
+ }),
43
36
  ],
44
37
  })
@@ -1,16 +1,10 @@
1
- /**
2
- * Annotations are ways of marking up text in the block content editor.
3
- *
4
- * Read more: https://www.sanity.io/docs/customization#f924645007e1
5
- */
6
1
  import {LinkIcon} from '@sanity/icons'
7
- import React from 'react'
8
2
  import {defineField} from 'sanity'
9
- import {PAGE_REFERENCES} from '../../constants'
3
+ import {PAGE_REFERENCES} from '../../../constants'
10
4
 
11
- export default defineField({
5
+ export const linkInternalType = defineField({
12
6
  title: 'Internal Link',
13
- name: 'annotationLinkInternal',
7
+ name: 'linkInternal',
14
8
  type: 'object',
15
9
  icon: LinkIcon,
16
10
  components: {
@@ -28,13 +22,12 @@ export default defineField({
28
22
  ),
29
23
  },
30
24
  fields: [
31
- // Reference
32
- {
25
+ defineField({
33
26
  name: 'reference',
34
27
  type: 'reference',
35
28
  weak: true,
36
29
  validation: (Rule) => Rule.required(),
37
30
  to: PAGE_REFERENCES,
38
- },
31
+ }),
39
32
  ],
40
33
  })
@@ -1,15 +1,9 @@
1
- /**
2
- * Annotations are ways of marking up text in the block content editor.
3
- *
4
- * Read more: https://www.sanity.io/docs/customization#f924645007e1
5
- */
6
1
  import {TagIcon} from '@sanity/icons'
7
- import React from 'react'
8
2
  import {defineField} from 'sanity'
9
3
 
10
- export default defineField({
4
+ export const linkProductType = defineField({
11
5
  title: 'Product',
12
- name: 'annotationProduct',
6
+ name: 'linkProduct',
13
7
  type: 'object',
14
8
  icon: TagIcon,
15
9
  components: {
@@ -27,17 +21,13 @@ export default defineField({
27
21
  ),
28
22
  },
29
23
  fields: [
30
- // Product
31
- {
24
+ defineField({
32
25
  name: 'productWithVariant',
33
- title: 'Product + Variant',
34
26
  type: 'productWithVariant',
35
27
  validation: (Rule) => Rule.required(),
36
- },
37
- // Link action
28
+ }),
38
29
  defineField({
39
30
  name: 'linkAction',
40
- title: 'Link action',
41
31
  type: 'string',
42
32
  initialValue: 'link',
43
33
  options: {
@@ -59,10 +49,8 @@ export default defineField({
59
49
  },
60
50
  validation: (Rule) => Rule.required(),
61
51
  }),
62
- // Quantity
63
52
  defineField({
64
53
  name: 'quantity',
65
- title: 'Quantity',
66
54
  type: 'number',
67
55
  initialValue: 1,
68
56
  hidden: ({parent}) => parent.linkAction === 'link',
@@ -1,35 +1,32 @@
1
1
  import {defineField} from 'sanity'
2
2
  import blocksToText from '../../../utils/blocksToText'
3
3
 
4
- export default defineField({
4
+ export const accordionGroupType = defineField({
5
5
  name: 'accordionGroup',
6
- title: 'Object',
6
+ title: 'Accordion Group',
7
7
  type: 'object',
8
8
  icon: false,
9
9
  fields: [
10
10
  defineField({
11
11
  name: 'title',
12
- title: 'Title',
13
12
  type: 'string',
14
13
  validation: (Rule) => Rule.required(),
15
14
  }),
16
15
  defineField({
17
16
  name: 'body',
18
- title: 'Body',
19
- type: 'accordionBody',
17
+ type: 'portableTextSimple',
20
18
  validation: (Rule) => Rule.required(),
21
19
  }),
22
20
  ],
23
21
  preview: {
24
22
  select: {
25
- body: 'body',
26
23
  title: 'title',
24
+ body: 'body',
27
25
  },
28
- prepare(selection) {
29
- const {body, title} = selection
26
+ prepare({title, body}) {
30
27
  return {
31
- subtitle: body && blocksToText(body),
32
28
  title,
29
+ subtitle: body && blocksToText(body),
33
30
  }
34
31
  },
35
32
  },
@@ -2,30 +2,23 @@ import {StackCompactIcon} from '@sanity/icons'
2
2
  import pluralize from 'pluralize-esm'
3
3
  import {defineField} from 'sanity'
4
4
 
5
- export default defineField({
6
- name: 'module.accordion',
5
+ export const accordionType = defineField({
6
+ name: 'accordion',
7
7
  title: 'Accordion',
8
8
  type: 'object',
9
9
  icon: StackCompactIcon,
10
10
  fields: [
11
- // Groups
12
11
  defineField({
13
12
  name: 'groups',
14
- title: 'Groups',
15
13
  type: 'array',
16
- of: [
17
- {
18
- type: 'accordionGroup',
19
- },
20
- ],
14
+ of: [{type: 'accordionGroup'}],
21
15
  }),
22
16
  ],
23
17
  preview: {
24
18
  select: {
25
19
  groups: 'groups',
26
20
  },
27
- prepare(selection) {
28
- const {groups} = selection
21
+ prepare({groups}) {
29
22
  return {
30
23
  subtitle: 'Accordion',
31
24
  title: groups?.length > 0 ? pluralize('group', groups.length, true) : 'No groups',
@@ -1,8 +1,8 @@
1
1
  import {BlockElementIcon, ImageIcon} from '@sanity/icons'
2
- import {defineField} from 'sanity'
2
+ import {defineArrayMember, defineField} from 'sanity'
3
3
 
4
- export default defineField({
5
- name: 'module.callToAction',
4
+ export const callToActionType = defineField({
5
+ name: 'callToAction',
6
6
  title: 'Call to action',
7
7
  type: 'object',
8
8
  icon: BlockElementIcon,
@@ -13,10 +13,8 @@ export default defineField({
13
13
  },
14
14
  ],
15
15
  fields: [
16
- // Layout
17
16
  defineField({
18
17
  name: 'layout',
19
- title: 'Layout direction',
20
18
  type: 'string',
21
19
  initialValue: 'left',
22
20
  options: {
@@ -35,50 +33,40 @@ export default defineField({
35
33
  },
36
34
  validation: (Rule) => Rule.required(),
37
35
  }),
38
- // Title
39
36
  defineField({
40
37
  name: 'title',
41
- title: 'Title',
42
38
  type: 'string',
43
39
  validation: (Rule) => Rule.required(),
44
40
  fieldset: 'copy',
45
41
  }),
46
- // Body
47
42
  defineField({
48
- name: 'body',
49
- title: 'Body',
43
+ name: 'portableText',
50
44
  type: 'text',
51
45
  rows: 2,
52
46
  fieldset: 'copy',
53
47
  }),
54
- // Link
55
48
  defineField({
56
- name: 'links',
57
- title: 'Link',
49
+ name: 'link',
58
50
  type: 'array',
59
51
  of: [{type: 'linkInternal'}, {type: 'linkExternal'}],
60
52
  validation: (Rule) => Rule.max(1),
61
53
  fieldset: 'copy',
62
54
  }),
63
- // Content
64
55
  defineField({
65
56
  name: 'content',
66
- title: 'Content',
67
57
  type: 'array',
68
58
  validation: (Rule) => Rule.required().max(1),
69
59
  of: [
70
- {
60
+ defineArrayMember({
71
61
  icon: ImageIcon,
72
62
  type: 'image',
73
- title: 'Image',
74
63
  options: {hotspot: true},
75
- },
76
- {
64
+ }),
65
+ defineArrayMember({
77
66
  name: 'productWithVariant',
78
- title: 'Product + Variant',
79
67
  type: 'productWithVariant',
80
68
  validation: (Rule) => Rule.required(),
81
- },
69
+ }),
82
70
  ],
83
71
  }),
84
72
  ],
@@ -86,8 +74,7 @@ export default defineField({
86
74
  select: {
87
75
  title: 'title',
88
76
  },
89
- prepare(selection) {
90
- const {title} = selection
77
+ prepare({title}) {
91
78
  return {
92
79
  subtitle: 'Call to action',
93
80
  title,
@@ -1,16 +1,14 @@
1
1
  import {BulbOutlineIcon} from '@sanity/icons'
2
2
  import {defineField} from 'sanity'
3
3
 
4
- export default defineField({
5
- name: 'module.callout',
4
+ export const calloutType = defineField({
5
+ name: 'callout',
6
6
  title: 'Callout',
7
7
  type: 'object',
8
8
  icon: BulbOutlineIcon,
9
9
  fields: [
10
- // Text
11
10
  defineField({
12
11
  name: 'text',
13
- title: 'Text',
14
12
  type: 'text',
15
13
  rows: 2,
16
14
  validation: (Rule) => [
@@ -18,10 +16,8 @@ export default defineField({
18
16
  Rule.max(70).warning(`Callout length shouldn't be more than 70 characters.`),
19
17
  ],
20
18
  }),
21
- // Link
22
19
  defineField({
23
- name: 'links',
24
- title: 'Link',
20
+ name: 'link',
25
21
  type: 'array',
26
22
  of: [{type: 'linkInternal'}, {type: 'linkExternal'}],
27
23
  validation: (Rule) => Rule.max(1),
@@ -30,10 +26,8 @@ export default defineField({
30
26
  preview: {
31
27
  select: {
32
28
  text: 'text',
33
- url: 'url',
34
29
  },
35
- prepare(selection) {
36
- const {text, url} = selection
30
+ prepare({text}) {
37
31
  return {
38
32
  subtitle: 'Callout',
39
33
  title: text,
@@ -1,28 +1,24 @@
1
- import React from 'react'
1
+
2
2
  import {PackageIcon} from '@sanity/icons'
3
3
  import {defineField} from 'sanity'
4
4
 
5
5
  import ShopifyDocumentStatus from '../../../components/media/ShopifyDocumentStatus'
6
6
 
7
- export default defineField({
8
- name: 'module.collection',
7
+ export const collectionReferenceType = defineField({
8
+ name: 'collectionReference',
9
9
  title: 'Collection',
10
10
  type: 'object',
11
11
  icon: PackageIcon,
12
12
  fields: [
13
- // Collection
14
13
  defineField({
15
14
  name: 'collection',
16
- title: 'Collection',
17
15
  type: 'reference',
18
16
  weak: true,
19
17
  to: [{type: 'collection'}],
20
18
  validation: (Rule) => Rule.required(),
21
19
  }),
22
- // Show background
23
20
  defineField({
24
21
  name: 'showBackground',
25
- title: 'Show background',
26
22
  type: 'boolean',
27
23
  description: 'Use Shopify collection image as background (if available)',
28
24
  initialValue: false,
@@ -34,8 +30,7 @@ export default defineField({
34
30
  imageUrl: 'collection.store.imageUrl',
35
31
  isDeleted: 'collection.store.isDeleted',
36
32
  },
37
- prepare(selection) {
38
- const {collectionTitle, imageUrl, isDeleted} = selection
33
+ prepare({collectionTitle, imageUrl, isDeleted}) {
39
34
  return {
40
35
  media: (
41
36
  <ShopifyDocumentStatus
@@ -0,0 +1,41 @@
1
+ import {defineField} from 'sanity'
2
+
3
+ import blocksToText from '../../../utils/blocksToText'
4
+
5
+ export const gridItemType = defineField({
6
+ name: 'gridItem',
7
+ title: 'Grid Item',
8
+ type: 'object',
9
+ fields: [
10
+ defineField({
11
+ name: 'title',
12
+ type: 'string',
13
+ validation: (Rule) => Rule.required(),
14
+ }),
15
+ defineField({
16
+ name: 'image',
17
+ type: 'image',
18
+ options: {hotspot: true},
19
+ validation: (Rule) => Rule.required(),
20
+ }),
21
+ defineField({
22
+ name: 'body',
23
+ type: 'portableTextSimple',
24
+ validation: (Rule) => Rule.required(),
25
+ }),
26
+ ],
27
+ preview: {
28
+ select: {
29
+ body: 'body',
30
+ image: 'image',
31
+ title: 'title',
32
+ },
33
+ prepare({body, image, title}) {
34
+ return {
35
+ media: image,
36
+ subtitle: body && blocksToText(body),
37
+ title,
38
+ }
39
+ },
40
+ },
41
+ })
@@ -1,32 +1,24 @@
1
1
  import {ThLargeIcon} from '@sanity/icons'
2
2
  import pluralize from 'pluralize-esm'
3
- import {defineField} from 'sanity'
3
+ import {defineArrayMember, defineField} from 'sanity'
4
4
 
5
- export default defineField({
6
- name: 'module.grid',
5
+ export const gridType = defineField({
6
+ name: 'grid',
7
7
  title: 'Grid',
8
8
  type: 'object',
9
9
  icon: ThLargeIcon,
10
10
  fields: [
11
- // Items
12
- {
11
+ defineField({
13
12
  name: 'items',
14
- title: 'Items',
15
13
  type: 'array',
16
- of: [
17
- {
18
- type: 'gridItem',
19
- },
20
- ],
21
- },
14
+ of: [defineArrayMember({type: 'gridItem'})],
15
+ }),
22
16
  ],
23
17
  preview: {
24
18
  select: {
25
19
  items: 'items',
26
- url: 'url',
27
20
  },
28
- prepare(selection) {
29
- const {items} = selection
21
+ prepare({items}) {
30
22
  return {
31
23
  subtitle: 'Grid',
32
24
  title: items?.length > 0 ? pluralize('item', items.length, true) : 'No items',
@@ -1,42 +1,39 @@
1
- import {defineField} from 'sanity'
1
+ import {defineArrayMember, defineField} from 'sanity'
2
2
 
3
- export default defineField({
4
- name: 'hero.home',
5
- title: 'Home hero',
3
+ export const heroType = defineField({
4
+ name: 'hero',
5
+ title: 'Hero',
6
6
  type: 'object',
7
7
  fields: [
8
- // Title
9
8
  defineField({
10
9
  name: 'title',
11
- title: 'Title',
12
10
  type: 'text',
13
11
  rows: 3,
14
12
  }),
15
- // Link
16
13
  defineField({
17
- name: 'links',
18
- title: 'Link',
14
+ name: 'description',
15
+ type: 'text',
16
+ rows: 3,
17
+ }),
18
+ defineField({
19
+ name: 'link',
19
20
  type: 'array',
20
21
  of: [{type: 'linkInternal'}, {type: 'linkExternal'}],
21
22
  validation: (Rule) => Rule.max(1),
22
23
  }),
23
- // Content
24
24
  defineField({
25
25
  name: 'content',
26
- title: 'Content',
27
26
  type: 'array',
28
27
  validation: (Rule) => Rule.max(1),
29
28
  of: [
30
- {
29
+ defineArrayMember({
31
30
  name: 'productWithVariant',
32
- title: 'Product with variant',
33
31
  type: 'productWithVariant',
34
- },
35
- {
32
+ }),
33
+ defineArrayMember({
36
34
  name: 'imageWithProductHotspots',
37
- title: 'Image',
38
35
  type: 'imageWithProductHotspots',
39
- },
36
+ }),
40
37
  ],
41
38
  }),
42
39
  ],