diff --git a/packages/@sanity/cli/src/actions/init-project/templates/shopify.ts b/packages/@sanity/cli/src/actions/init-project/templates/shopify.ts
index bb28d29caab..2701f895f59 100644
--- a/packages/@sanity/cli/src/actions/init-project/templates/shopify.ts
+++ b/packages/@sanity/cli/src/actions/init-project/templates/shopify.ts
@@ -12,6 +12,7 @@ import {colorInput} from '@sanity/color-input'
import {imageHotspotArrayPlugin} from 'sanity-plugin-hotspot-array'
import {media, mediaAssetSource} from 'sanity-plugin-media'
import {customDocumentActions} from './plugins/customDocumentActions'
+import Navbar from './components/studio/Navbar'
const devOnlyPlugins = [visionTool()]
@@ -47,6 +48,12 @@ export default defineConfig({
},
},
},
+
+ studio: {
+ components: {
+ navbar: Navbar,
+ },
+ },
})`
const shopifyTemplate: ProjectTemplate = {
diff --git a/packages/@sanity/cli/templates/shopify/README.md b/packages/@sanity/cli/templates/shopify/README.md
index 66623aa9ad1..eea68ceb45d 100644
--- a/packages/@sanity/cli/templates/shopify/README.md
+++ b/packages/@sanity/cli/templates/shopify/README.md
@@ -1,6 +1,6 @@
# Sanity Studio for Shopify Projects
-
+
## About
@@ -8,11 +8,11 @@ This Sanity Studio is configured for headless Shopify projects that use the offi
It contains examples of customizing your [structure][docs-structure], [document actions][docs-document-actions] and [input components][docs-input-components].
-This studio can be used with our [Hydrogen starter][hydrogen-demo], your frontend, or anywhere else you want your e-commerce content to go.
+This studio can be used with any front end, or anywhere else you want your e-commerce content to go.
## Features
-This studio comes preconfigured with Shopify-friendly content schema types and a whole host of customizations to make managing Shopify data in your Sanity studio easier.
+This studio comes configured with Shopify-friendly content schema types and a whole host of customizations to make managing Shopify data in your Sanity studio easier.
It also comes with several convenient layout modules which can be re-used across various pages.
diff --git a/packages/@sanity/cli/templates/shopify/components/icons/Shopify.tsx b/packages/@sanity/cli/templates/shopify/components/icons/Shopify.tsx
index ced1bc93080..604560dba5b 100644
--- a/packages/@sanity/cli/templates/shopify/components/icons/Shopify.tsx
+++ b/packages/@sanity/cli/templates/shopify/components/icons/Shopify.tsx
@@ -1,4 +1,4 @@
-import React from 'react'
+
const ShopifyIcon = () => {
return (
diff --git a/packages/@sanity/cli/templates/shopify/components/inputs/CollectionHidden.tsx b/packages/@sanity/cli/templates/shopify/components/inputs/CollectionHidden.tsx
index 7236fd5bdd3..45d7217d2c5 100644
--- a/packages/@sanity/cli/templates/shopify/components/inputs/CollectionHidden.tsx
+++ b/packages/@sanity/cli/templates/shopify/components/inputs/CollectionHidden.tsx
@@ -1,4 +1,4 @@
-import React from 'react'
+
import {WarningOutlineIcon} from '@sanity/icons'
import {StringFieldProps} from 'sanity'
import {Box, Card, Flex, Stack, Text} from '@sanity/ui'
diff --git a/packages/@sanity/cli/templates/shopify/components/studio/Navbar.tsx b/packages/@sanity/cli/templates/shopify/components/studio/Navbar.tsx
new file mode 100644
index 00000000000..c9f57c15b71
--- /dev/null
+++ b/packages/@sanity/cli/templates/shopify/components/studio/Navbar.tsx
@@ -0,0 +1,29 @@
+import {Box, Button, Card, Flex} from '@sanity/ui'
+import type {NavbarProps} from 'sanity'
+
+import {SHOPIFY_STORE_ID} from '../../constants'
+import ShopifyIcon from '../icons/Shopify'
+
+export default function Navbar(props: NavbarProps) {
+ if (!SHOPIFY_STORE_ID) return props.renderDefault(props)
+
+ return (
+
+
+ {props.renderDefault(props)}
+
+
+
+
+
+ )
+}
diff --git a/packages/@sanity/cli/templates/shopify/constants.ts b/packages/@sanity/cli/templates/shopify/constants.ts
index 87c08fbbdb1..f2525ec0e32 100644
--- a/packages/@sanity/cli/templates/shopify/constants.ts
+++ b/packages/@sanity/cli/templates/shopify/constants.ts
@@ -1,4 +1,8 @@
// Currency code (ISO 4217) to use when displaying prices in the studio
+
+import ShopifyIcon from "./components/icons/Shopify"
+import { ColorWheelIcon, ComposeIcon, SearchIcon } from '@sanity/icons'
+
// https://en.wikipedia.org/wiki/ISO_4217
export const DEFAULT_CURRENCY_CODE = 'USD'
@@ -26,6 +30,32 @@ export const PAGE_REFERENCES = [
export const SANITY_API_VERSION = '2022-10-25'
// Your Shopify store ID.
-// This is your unique store URL (e.g. 'my-store-name.myshopify.com').
+// This is the ID in your Shopify admin URL (e.g. 'my-store-name' in https://admin.shopify.com/store/my-store-name).
+// You only need to provide the ID, not the full URL.
// Set this to enable helper links in document status banners and shortcut links on products and collections.
export const SHOPIFY_STORE_ID = ''
+
+// Field groups used through schema types
+export const GROUPS = [
+ {
+ name: 'theme',
+ title: 'Theme',
+ icon: ColorWheelIcon,
+ },
+ {
+ default: true,
+ name: 'editorial',
+ title: 'Editorial',
+ icon: ComposeIcon
+ },
+ {
+ name: 'shopifySync',
+ title: 'Shopify sync',
+ icon: ShopifyIcon,
+ },
+ {
+ name: 'seo',
+ title: 'SEO',
+ icon: SearchIcon
+ },
+]
diff --git a/packages/@sanity/cli/templates/shopify/docs/features.md b/packages/@sanity/cli/templates/shopify/docs/features.md
index 6ed82d50121..23af97500c7 100644
--- a/packages/@sanity/cli/templates/shopify/docs/features.md
+++ b/packages/@sanity/cli/templates/shopify/docs/features.md
@@ -73,7 +73,7 @@ Read more about [document actions][docs-document-actions].
`/plugins/customDocumentActions/shopifyDelete.tsx`
-Delete a product document including all its associated variants in your Sanity Content Lake. Without this document action, one would have to delete all variant document one-by-one.
+Delete a product document including all its associated variants in your Sanity Content Lake. Without this document action, one would have to delete all variant documents one-by-one.
### Edit in Shopify shortcut
@@ -96,12 +96,11 @@ A simple wrapper around a regular [string input](string-input) that uses the val
**Usage:**
```javascript
-{
+defineField({
name: 'title',
- title: 'Title',
type: 'placeholderString',
options: { field: 'store.title' }
-},
+}),
```
### Shopify document status (for collections, products and product variants)
@@ -129,12 +128,12 @@ Since we are using certain product fields from Shopify as the source of truth (s
**Usage**
```javascript
-{
+defineField({
title: 'Slug',
name: 'slugProxy',
type: 'proxyString',
- options: { field: 'store.slug.current' }
-}
+ options: {field: 'store.slug.current'},
+})
```
### Shopify document status (preview component)
diff --git a/packages/@sanity/cli/templates/shopify/schemaTypes/blocks/body.tsx b/packages/@sanity/cli/templates/shopify/schemaTypes/blocks/body.tsx
deleted file mode 100644
index 9d0790d5cf8..00000000000
--- a/packages/@sanity/cli/templates/shopify/schemaTypes/blocks/body.tsx
+++ /dev/null
@@ -1,70 +0,0 @@
-import {defineField} from 'sanity'
-
-export default defineField({
- name: 'body',
- title: 'Body',
- type: 'array',
- of: [
- {
- lists: [
- {title: 'Bullet', value: 'bullet'},
- {title: 'Numbered', value: 'number'},
- ],
- marks: {
- decorators: [
- {
- title: 'Italic',
- value: 'em',
- },
- {
- title: 'Strong',
- value: 'strong',
- },
- ],
- annotations: [
- // product
- {
- name: 'annotationProduct',
- type: 'annotationProduct',
- },
- // Email
- {
- name: 'annotationLinkEmail',
- type: 'annotationLinkEmail',
- },
- // Internal link
- {
- name: 'annotationLinkInternal',
- type: 'annotationLinkInternal',
- },
- // URL
- {
- name: 'annotationLinkExternal',
- type: 'annotationLinkExternal',
- },
- ],
- },
- // Paragraphs
- type: 'block',
- },
- // Custom blocks
- {
- type: 'module.accordion',
- },
- {
- type: 'module.callout',
- },
- {
- type: 'module.grid',
- },
- {
- type: 'module.images',
- },
- {
- type: 'module.instagram',
- },
- {
- type: 'module.products',
- },
- ],
-})
diff --git a/packages/@sanity/cli/templates/shopify/schemaTypes/documents/collection.tsx b/packages/@sanity/cli/templates/shopify/schemaTypes/documents/collection.tsx
index d483bce39cd..11a5a6c13d1 100644
--- a/packages/@sanity/cli/templates/shopify/schemaTypes/documents/collection.tsx
+++ b/packages/@sanity/cli/templates/shopify/schemaTypes/documents/collection.tsx
@@ -1,41 +1,19 @@
-import React from 'react'
-import {defineField, defineType} from 'sanity'
+
+import {defineArrayMember, defineField, defineType} from 'sanity'
import {PackageIcon} from '@sanity/icons'
import {getExtension} from '@sanity/asset-utils'
import pluralize from 'pluralize-esm'
import CollectionHiddenInput from '../../components/inputs/CollectionHidden'
-import ShopifyIcon from '../../components/icons/Shopify'
import ShopifyDocumentStatus from '../../components/media/ShopifyDocumentStatus'
+import { GROUPS } from '../../constants'
-const GROUPS = [
- {
- name: 'theme',
- title: 'Theme',
- },
- {
- default: true,
- name: 'editorial',
- title: 'Editorial',
- },
- {
- name: 'shopifySync',
- title: 'Shopify sync',
- icon: ShopifyIcon,
- },
- {
- name: 'seo',
- title: 'SEO',
- },
-]
-
-export default defineType({
+export const collectionType = defineType({
name: 'collection',
title: 'Collection',
type: 'document',
icon: PackageIcon,
groups: GROUPS,
fields: [
- // Product hidden status
defineField({
name: 'hidden',
type: 'string',
@@ -47,29 +25,24 @@ export default defineType({
return !isDeleted
},
}),
- // Title (proxy)
defineField({
name: 'titleProxy',
title: 'Title',
type: 'proxyString',
options: {field: 'store.title'},
}),
- // Slug (proxy)
defineField({
name: 'slugProxy',
title: 'Slug',
type: 'proxyString',
options: {field: 'store.slug.current'},
}),
- // Color theme
defineField({
name: 'colorTheme',
- title: 'Color theme',
type: 'reference',
to: [{type: 'colorTheme'}],
group: 'theme',
}),
- // Vector
defineField({
name: 'vector',
title: 'Vector artwork',
@@ -93,37 +66,30 @@ export default defineType({
return true
}),
}),
- // Show hero
defineField({
name: 'showHero',
- title: 'Show hero',
type: 'boolean',
description: 'If disabled, page title will be displayed instead',
group: 'editorial',
}),
- // Hero
defineField({
name: 'hero',
- title: 'Hero',
- type: 'hero.collection',
+ type: 'hero',
hidden: ({document}) => !document?.showHero,
group: 'editorial',
}),
- // Modules
defineField({
name: 'modules',
- title: 'Modules',
type: 'array',
description: 'Editorial modules to associate with this collection',
of: [
- {type: 'module.callout'},
- {type: 'module.callToAction'},
- {type: 'module.image'},
- {type: 'module.instagram'},
+ defineArrayMember({type: 'callout'}),
+ defineArrayMember({type: 'callToAction'}),
+ defineArrayMember({type: 'image'}),
+ defineArrayMember({type: 'instagram'}),
],
group: 'editorial',
}),
- // Shopify collection
defineField({
name: 'store',
title: 'Shopify',
@@ -131,11 +97,10 @@ export default defineType({
description: 'Collection data from Shopify (read-only)',
group: 'shopifySync',
}),
- // SEO
defineField({
name: 'seo',
title: 'SEO',
- type: 'seo.shopify',
+ type: 'seo',
group: 'seo',
}),
],
@@ -158,8 +123,7 @@ export default defineType({
rules: 'store.rules',
title: 'store.title',
},
- prepare(selection) {
- const {imageUrl, isDeleted, rules, title} = selection
+ prepare({imageUrl, isDeleted, rules, title}) {
const ruleCount = rules?.length || 0
return {
diff --git a/packages/@sanity/cli/templates/shopify/schemaTypes/documents/colorTheme.tsx b/packages/@sanity/cli/templates/shopify/schemaTypes/documents/colorTheme.tsx
index a70aad0449a..94634a5f568 100644
--- a/packages/@sanity/cli/templates/shopify/schemaTypes/documents/colorTheme.tsx
+++ b/packages/@sanity/cli/templates/shopify/schemaTypes/documents/colorTheme.tsx
@@ -1,40 +1,27 @@
import {IceCreamIcon} from '@sanity/icons'
-import React from 'react'
import {defineField, defineType} from 'sanity'
import ColorTheme from '../../components/media/ColorTheme'
-export default defineType({
+export const colorThemeType = defineType({
name: 'colorTheme',
title: 'Color theme',
type: 'document',
icon: IceCreamIcon,
- groups: [
- {
- name: 'shopifySync',
- title: 'Shopify sync',
- },
- ],
fields: [
- // Title
defineField({
name: 'title',
- title: 'Title',
type: 'string',
validation: (Rule) => Rule.required(),
}),
- // Text color
defineField({
name: 'text',
- title: 'Text',
type: 'color',
options: {disableAlpha: true},
validation: (Rule) => Rule.required(),
}),
- // Background color
defineField({
name: 'background',
- title: 'Background',
type: 'color',
options: {disableAlpha: true},
validation: (Rule) => Rule.required(),
@@ -46,9 +33,7 @@ export default defineType({
textColor: 'text.hex',
title: 'title',
},
- prepare(selection) {
- const {backgroundColor, textColor, title} = selection
-
+ prepare({backgroundColor, textColor, title}) {
return {
media: ,
subtitle: `${textColor || '(No color)'} / ${backgroundColor || '(No color)'}`,
diff --git a/packages/@sanity/cli/templates/shopify/schemaTypes/documents/page.ts b/packages/@sanity/cli/templates/shopify/schemaTypes/documents/page.ts
index c3272018029..7d37a788e81 100644
--- a/packages/@sanity/cli/templates/shopify/schemaTypes/documents/page.ts
+++ b/packages/@sanity/cli/templates/shopify/schemaTypes/documents/page.ts
@@ -2,94 +2,67 @@ import {DocumentIcon} from '@sanity/icons'
import {defineField} from 'sanity'
import {validateSlug} from '../../utils/validateSlug'
+import { GROUPS } from '../../constants'
-export default defineField({
+export const pageType = defineField({
name: 'page',
title: 'Page',
type: 'document',
icon: DocumentIcon,
- groups: [
- {
- name: 'theme',
- title: 'Theme',
- },
- {
- default: true,
- name: 'editorial',
- title: 'Editorial',
- },
- {
- name: 'seo',
- title: 'SEO',
- },
- ],
+ groups: GROUPS,
fields: [
- // Title
defineField({
name: 'title',
- title: 'Title',
+ group: 'editorial',
type: 'string',
validation: (Rule) => Rule.required(),
}),
- // Slug
defineField({
name: 'slug',
+ group: 'editorial',
type: 'slug',
options: {source: 'title'},
- // @ts-ignore - TODO - fix this TS error
validation: validateSlug,
}),
- // Color theme
defineField({
name: 'colorTheme',
- title: 'Color theme',
type: 'reference',
to: [{type: 'colorTheme'}],
group: 'theme',
}),
- // Show hero
defineField({
name: 'showHero',
- title: 'Show hero',
type: 'boolean',
description: 'If disabled, page title will be displayed instead',
initialValue: false,
group: 'editorial',
}),
- // Hero
defineField({
name: 'hero',
- title: 'Hero',
- type: 'hero.page',
+ type: 'hero',
hidden: ({document}) => !document?.showHero,
group: 'editorial',
}),
- // Body
defineField({
name: 'body',
- title: 'Body',
- type: 'body',
+ type: 'portableText',
group: 'editorial',
}),
- // SEO
defineField({
name: 'seo',
title: 'SEO',
- type: 'seo.page',
+ type: 'seo',
group: 'seo',
}),
],
preview: {
select: {
- active: 'active',
seoImage: 'seo.image',
title: 'title',
},
- prepare(selection) {
- const {seoImage, title} = selection
-
+ prepare({seoImage, title}) {
return {
- media: seoImage,
+ media: seoImage ?? DocumentIcon,
title,
}
},
diff --git a/packages/@sanity/cli/templates/shopify/schemaTypes/documents/product.tsx b/packages/@sanity/cli/templates/shopify/schemaTypes/documents/product.tsx
index e7ef64c0a55..b413b9602f7 100644
--- a/packages/@sanity/cli/templates/shopify/schemaTypes/documents/product.tsx
+++ b/packages/@sanity/cli/templates/shopify/schemaTypes/documents/product.tsx
@@ -1,29 +1,12 @@
import {TagIcon} from '@sanity/icons'
import pluralize from 'pluralize-esm'
-import ShopifyIcon from '../../components/icons/Shopify'
import ProductHiddenInput from '../../components/inputs/ProductHidden'
import ShopifyDocumentStatus from '../../components/media/ShopifyDocumentStatus'
import {defineField, defineType} from 'sanity'
import {getPriceRange} from '../../utils/getPriceRange'
+import { GROUPS } from '../../constants'
-const GROUPS = [
- {
- name: 'editorial',
- title: 'Editorial',
- default: true,
- },
- {
- name: 'shopifySync',
- title: 'Shopify sync',
- icon: ShopifyIcon,
- },
- {
- name: 'seo',
- title: 'SEO',
- },
-]
-
-export default defineType({
+export const productType = defineType({
name: 'product',
title: 'Product',
type: 'document',
@@ -43,37 +26,31 @@ export default defineType({
return !parent?.store || (isActive && !isDeleted)
},
}),
- // Title (proxy)
defineField({
name: 'titleProxy',
title: 'Title',
type: 'proxyString',
options: {field: 'store.title'},
}),
- // Slug (proxy)
defineField({
name: 'slugProxy',
title: 'Slug',
type: 'proxyString',
options: {field: 'store.slug.current'},
}),
- // Color theme
defineField({
name: 'colorTheme',
- title: 'Color theme',
type: 'reference',
to: [{type: 'colorTheme'}],
group: 'editorial',
}),
defineField({
name: 'body',
- title: 'Body',
- type: 'body',
+ type: 'portableText',
group: 'editorial',
}),
defineField({
name: 'store',
- title: 'Shopify',
type: 'shopifyProduct',
description: 'Product data from Shopify (read-only)',
group: 'shopifySync',
@@ -81,7 +58,7 @@ export default defineType({
defineField({
name: 'seo',
title: 'SEO',
- type: 'seo.shopify',
+ type: 'seo',
group: 'seo',
}),
],
diff --git a/packages/@sanity/cli/templates/shopify/schemaTypes/documents/productVariant.tsx b/packages/@sanity/cli/templates/shopify/schemaTypes/documents/productVariant.tsx
index 73c6e7f7127..c52f33f43df 100644
--- a/packages/@sanity/cli/templates/shopify/schemaTypes/documents/productVariant.tsx
+++ b/packages/@sanity/cli/templates/shopify/schemaTypes/documents/productVariant.tsx
@@ -1,25 +1,18 @@
-import React from 'react'
+
import { CopyIcon } from '@sanity/icons'
import {defineField, defineType} from 'sanity'
-import ShopifyIcon from '../../components/icons/Shopify'
import ProductVariantHiddenInput from '../../components/inputs/ProductVariantHidden'
import ShopifyDocumentStatus from '../../components/media/ShopifyDocumentStatus'
+import { GROUPS } from '../../constants'
-export default defineType({
+export const productVariantType = defineType({
name: 'productVariant',
title: 'Product variant',
type: 'document',
icon: CopyIcon,
- groups: [
- {
- name: 'shopifySync',
- title: 'Shopify sync',
- icon: ShopifyIcon,
- },
- ],
+ groups: GROUPS,
fields: [
- // Product variant hidden status
defineField({
name: 'hidden',
type: 'string',
@@ -32,14 +25,12 @@ export default defineType({
return !isDeleted
},
}),
- // Title (proxy)
defineField({
title: 'Title',
name: 'titleProxy',
type: 'proxyString',
options: {field: 'store.title'},
}),
- // Shopify product variant
defineField({
name: 'store',
title: 'Shopify',
diff --git a/packages/@sanity/cli/templates/shopify/schemaTypes/index.ts b/packages/@sanity/cli/templates/shopify/schemaTypes/index.ts
index 71967419661..aa0370f7464 100644
--- a/packages/@sanity/cli/templates/shopify/schemaTypes/index.ts
+++ b/packages/@sanity/cli/templates/shopify/schemaTypes/index.ts
@@ -1,135 +1,106 @@
-// Rich text annotations used in the block content editor
-import annotationLinkEmail from './annotations/linkEmail'
-import annotationLinkExternal from './annotations/linkExternal'
-import annotationLinkInternal from './annotations/linkInternal'
-import annotationProduct from './annotations/product'
+import {accordionGroupType} from './objects/module/accordionGroupType'
+import {accordionType} from './objects/module/accordionType'
+import {calloutType} from './objects/module/calloutType'
+import {callToActionType} from './objects/module/callToActionType'
+import {collectionGroupType} from './objects/collection/collectionGroupType'
+import {collectionLinksType} from './objects/collection/collectionLinksType'
+import {collectionReferenceType} from './objects/module/collectionReferenceType'
+import {collectionRuleType} from './objects/shopify/collectionRuleType'
+import {customProductOptionColorObjectType} from './objects/customProductOption/customProductOptionColorObjectType'
+import {customProductOptionColorType} from './objects/customProductOption/customProductOptionColorType'
+import {customProductOptionSizeObjectType} from './objects/customProductOption/customProductOptionSizeObjectType'
+import {customProductOptionSizeType} from './objects/customProductOption/customProductOptionSizeType'
+import {footerType} from './objects/global/footerType'
+import {gridItemType} from './objects/module/gridItemType'
+import {gridType} from './objects/module/gridType'
+import {heroType} from './objects/module/heroType'
+import {imageCallToActionType} from './objects/module/imageCallToActionType'
+import {imageFeaturesType} from './objects/module/imageFeaturesType'
+import {imageFeatureType} from './objects/module/imageFeatureType'
+import {imageWithProductHotspotsType} from './objects/hotspot/imageWithProductHotspotsType'
+import {instagramType} from './objects/module/instagramType'
+import {inventoryType} from './objects/shopify/inventoryType'
+import {linkEmailType} from './objects/link/linkEmailType'
+import {linkExternalType} from './objects/link/linkExternalType'
+import {linkInternalType} from './objects/link/linkInternalType'
+import {linkProductType} from './objects/link/linkProductType'
+import {menuLinksType} from './objects/global/menuLinksType'
+import {menuType} from './objects/global/menuType'
+import {notFoundPageType} from './objects/global/notFoundPageType'
+import {optionType} from './objects/shopify/optionType'
+import {placeholderStringType} from './objects/shopify/placeholderStringType'
+import {priceRangeType} from './objects/shopify/priceRangeType'
+import {productFeaturesType} from './objects/module/productFeaturesType'
+import {productHotspotsType} from './objects/hotspot/productHotspotsType'
+import {productReferenceType} from './objects/module/productReferenceType'
+import {productWithVariantType} from './objects/shopify/productWithVariantType'
+import {proxyStringType} from './objects/shopify/proxyStringType'
+import {seoType} from './objects/seoType'
+import {shopifyCollectionType} from './objects/shopify/shopifyCollectionType'
+import {shopifyProductType} from './objects/shopify/shopifyProductType'
+import {shopifyProductVariantType} from './objects/shopify/shopifyProductVariantType'
+import {spotType} from './objects/hotspot/spotType'
-const annotations = [
- annotationLinkEmail,
- annotationLinkExternal,
- annotationLinkInternal,
- annotationProduct,
-]
-
-// Document types
-import collection from './documents/collection'
-import colorTheme from './documents/colorTheme'
-import page from './documents/page'
-import product from './documents/product'
-import productVariant from './documents/productVariant'
+// Objects used as annotations must be imported first
+const annotations = [linkEmailType, linkExternalType, linkInternalType, linkProductType]
-const documents = [collection, colorTheme, page, product, productVariant]
-
-// Singleton document types
-import home from './singletons/home'
-import settings from './singletons/settings'
+const objects = [
+ accordionGroupType,
+ accordionType,
+ calloutType,
+ callToActionType,
+ collectionGroupType,
+ collectionLinksType,
+ collectionReferenceType,
+ collectionRuleType,
+ customProductOptionColorObjectType,
+ customProductOptionColorType,
+ customProductOptionSizeObjectType,
+ customProductOptionSizeType,
+ footerType,
+ gridItemType,
+ gridType,
+ heroType,
+ imageCallToActionType,
+ imageFeaturesType,
+ imageFeatureType,
+ imageWithProductHotspotsType,
+ instagramType,
+ inventoryType,
+ menuLinksType,
+ menuType,
+ notFoundPageType,
+ optionType,
+ placeholderStringType,
+ priceRangeType,
+ productFeaturesType,
+ productHotspotsType,
+ productReferenceType,
+ productWithVariantType,
+ proxyStringType,
+ seoType,
+ shopifyCollectionType,
+ shopifyProductType,
+ shopifyProductVariantType,
+ spotType,
+]
-const singletons = [home, settings]
+import {portableTextType} from './portableText/portableTextType'
+import {portableTextSimpleType} from './portableText/portableTextSimpleType'
-// Block content
-import body from './blocks/body'
+const blocks = [portableTextType, portableTextSimpleType]
-const blocks = [body]
+import {collectionType} from './documents/collection'
+import {colorThemeType} from './documents/colorTheme'
+import {pageType} from './documents/page'
+import {productType} from './documents/product'
+import {productVariantType} from './documents/productVariant'
-// Object types
-import customProductOptionColor from './objects/customProductOption/color'
-import customProductOptionColorObject from './objects/customProductOption/colorObject'
-import customProductOptionSize from './objects/customProductOption/size'
-import customProductOptionSizeObject from './objects/customProductOption/sizeObject'
-import footer from './objects/global/footer'
-import imageWithProductHotspots from './objects/hotspot/imageWithProductHotspots'
-import inventory from './objects/shopify/inventory'
-import linkExternal from './objects/global/linkExternal'
-import linkInternal from './objects/global/linkInternal'
-import links from './objects/global/links'
-import notFoundPage from './objects/global/notFoundPage'
-import heroCollection from './objects/hero/collection'
-import heroHome from './objects/hero/home'
-import heroPage from './objects/hero/page'
-import moduleAccordion from './objects/module/accordion'
-import accordionBody from './objects/module/accordionBody'
-import accordionGroup from './objects/module/accordionGroup'
-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/gridItem'
-import menu from './objects/global/menu'
-import moduleImage from './objects/module/image'
-import moduleImageAction from './objects/module/imageCallToAction'
-import moduleImages from './objects/module/images'
-import moduleInstagram from './objects/module/instagram'
-import moduleProduct from './objects/module/product'
-import moduleProducts from './objects/module/products'
-import placeholderString from './objects/shopify/placeholderString'
-import priceRange from './objects/shopify/priceRange'
-import spot from './objects/hotspot/spot'
-import productHotspots from './objects/hotspot/productHotspots'
-import option from './objects/shopify/option'
-import productWithVariant from './objects/shopify/productWithVariant'
-import proxyString from './objects/shopify/proxyString'
-import seo from './objects/seo/seo'
-import seoHome from './objects/seo/home'
-import seoPage from './objects/seo/page'
-import seoDescription from './objects/seo/description'
-import seoShopify from './objects/seo/shopify'
-import shopifyCollection from './objects/shopify/shopifyCollection'
-import shopifyCollectionRule from './objects/shopify/shopifyCollectionRule'
-import shopifyProduct from './objects/shopify/shopifyProduct'
-import shopifyProductVariant from './objects/shopify/shopifyProductVariant'
+const documents = [collectionType, colorThemeType, pageType, productType, productVariantType]
-// Collections
-import collectionGroup from './objects/collection/group'
-import collectionLinks from './objects/collection/links'
+import {homeType} from './singletons/homeType'
+import {settingsType} from './singletons/settingsType'
-const objects = [
- customProductOptionColor,
- customProductOptionColorObject,
- customProductOptionSize,
- customProductOptionSizeObject,
- footer,
- imageWithProductHotspots,
- inventory,
- links,
- linkExternal,
- linkInternal,
- notFoundPage,
- heroCollection,
- heroHome,
- heroPage,
- moduleAccordion,
- accordionBody,
- accordionGroup,
- menu,
- moduleCallout,
- moduleCallToAction,
- moduleCollection,
- moduleGrid,
- gridItems,
- moduleImage,
- moduleImageAction,
- moduleImages,
- moduleInstagram,
- moduleProduct,
- moduleProducts,
- placeholderString,
- priceRange,
- spot,
- productHotspots,
- option,
- productWithVariant,
- proxyString,
- seo,
- seoHome,
- seoPage,
- seoDescription,
- seoShopify,
- shopifyCollection,
- shopifyCollectionRule,
- shopifyProduct,
- shopifyProductVariant,
- collectionGroup,
- collectionLinks,
-]
+const singletons = [homeType, settingsType]
-export const schemaTypes = [...annotations, ...singletons, ...objects, ...blocks, ...documents]
+export const schemaTypes = [...annotations, ...objects, ...singletons, ...blocks, ...documents]
diff --git a/packages/@sanity/cli/templates/shopify/schemaTypes/objects/collection/group.ts b/packages/@sanity/cli/templates/shopify/schemaTypes/objects/collection/collectionGroupType.ts
similarity index 76%
rename from packages/@sanity/cli/templates/shopify/schemaTypes/objects/collection/group.ts
rename to packages/@sanity/cli/templates/shopify/schemaTypes/objects/collection/collectionGroupType.ts
index 18d3f44baec..fb50e8f18d1 100644
--- a/packages/@sanity/cli/templates/shopify/schemaTypes/objects/collection/group.ts
+++ b/packages/@sanity/cli/templates/shopify/schemaTypes/objects/collection/collectionGroupType.ts
@@ -1,30 +1,27 @@
import {PackageIcon} from '@sanity/icons'
import {defineField} from 'sanity'
-export default defineField({
+export const collectionGroupType = defineField({
name: 'collectionGroup',
title: 'Collection group',
type: 'object',
icon: PackageIcon,
fields: [
- {
+ defineField({
name: 'title',
- title: 'Title',
type: 'string',
validation: (Rule) => Rule.required(),
- },
- {
+ }),
+ defineField({
name: 'collectionLinks',
- title: 'Collection links',
type: 'collectionLinks',
- },
- {
+ }),
+ defineField({
name: 'collectionProducts',
- title: 'Collection products',
type: 'reference',
description: 'Products from this collection will be listed',
weak: true,
to: [{type: 'collection'}],
- },
+ }),
],
})
diff --git a/packages/@sanity/cli/templates/shopify/schemaTypes/objects/collection/links.ts b/packages/@sanity/cli/templates/shopify/schemaTypes/objects/collection/collectionLinksType.ts
similarity index 63%
rename from packages/@sanity/cli/templates/shopify/schemaTypes/objects/collection/links.ts
rename to packages/@sanity/cli/templates/shopify/schemaTypes/objects/collection/collectionLinksType.ts
index bac2cc90ae3..f13ef4df121 100644
--- a/packages/@sanity/cli/templates/shopify/schemaTypes/objects/collection/links.ts
+++ b/packages/@sanity/cli/templates/shopify/schemaTypes/objects/collection/collectionLinksType.ts
@@ -1,16 +1,16 @@
-import {defineField} from 'sanity'
+import {defineArrayMember, defineField} from 'sanity'
-export default defineField({
+export const collectionLinksType = defineField({
name: 'collectionLinks',
title: 'Collection links',
type: 'array',
validation: (Rule) => Rule.unique().max(4),
of: [
- {
+ defineArrayMember({
name: 'collection',
type: 'reference',
weak: true,
to: [{type: 'collection'}],
- },
+ }),
],
})
diff --git a/packages/@sanity/cli/templates/shopify/schemaTypes/objects/customProductOption/colorObject.tsx b/packages/@sanity/cli/templates/shopify/schemaTypes/objects/customProductOption/customProductOptionColorObjectType.tsx
similarity index 84%
rename from packages/@sanity/cli/templates/shopify/schemaTypes/objects/customProductOption/colorObject.tsx
rename to packages/@sanity/cli/templates/shopify/schemaTypes/objects/customProductOption/customProductOptionColorObjectType.tsx
index 10afce52be5..d7648764622 100644
--- a/packages/@sanity/cli/templates/shopify/schemaTypes/objects/customProductOption/colorObject.tsx
+++ b/packages/@sanity/cli/templates/shopify/schemaTypes/objects/customProductOption/customProductOptionColorObjectType.tsx
@@ -1,4 +1,4 @@
-import React from 'react'
+
import {defineField} from 'sanity'
const ColorPreview = ({color}: {color: string}) => {
@@ -15,21 +15,19 @@ const ColorPreview = ({color}: {color: string}) => {
)
}
-export default defineField({
+export const customProductOptionColorObjectType = defineField({
name: 'customProductOption.colorObject',
title: 'Color',
type: 'object',
fields: [
defineField({
name: 'title',
- title: 'Title',
type: 'string',
description: 'Shopify product option value (case sensitive)',
validation: (Rule) => Rule.required(),
}),
defineField({
name: 'color',
- title: 'Color',
type: 'color',
options: {disableAlpha: true},
validation: (Rule) => Rule.required(),
@@ -40,8 +38,7 @@ export default defineField({
color: 'color.hex',
title: 'title',
},
- prepare(selection) {
- const {color, title} = selection
+ prepare({color, title}) {
return {
media: ,
subtitle: color,
diff --git a/packages/@sanity/cli/templates/shopify/schemaTypes/objects/customProductOption/color.tsx b/packages/@sanity/cli/templates/shopify/schemaTypes/objects/customProductOption/customProductOptionColorType.tsx
similarity index 85%
rename from packages/@sanity/cli/templates/shopify/schemaTypes/objects/customProductOption/color.tsx
rename to packages/@sanity/cli/templates/shopify/schemaTypes/objects/customProductOption/customProductOptionColorType.tsx
index 5eb9aafb761..44d3bfb2e5b 100644
--- a/packages/@sanity/cli/templates/shopify/schemaTypes/objects/customProductOption/color.tsx
+++ b/packages/@sanity/cli/templates/shopify/schemaTypes/objects/customProductOption/customProductOptionColorType.tsx
@@ -5,30 +5,22 @@ interface ColorOption {
title: string
}
-export default defineField({
+export const customProductOptionColorType = defineField({
name: 'customProductOption.color',
title: 'Color',
type: 'object',
icon: false,
fields: [
- // Title
defineField({
name: 'title',
- title: 'Title',
type: 'string',
description: 'Shopify product option name (case sensitive)',
validation: (Rule) => Rule.required(),
}),
- // Colors
defineField({
name: 'colors',
- title: 'Colors',
type: 'array',
- of: [
- {
- type: 'customProductOption.colorObject',
- },
- ],
+ of: [{type: 'customProductOption.colorObject'}],
validation: (Rule) =>
Rule.custom((options: ColorOption[] | undefined) => {
// Each size must have a unique title
diff --git a/packages/@sanity/cli/templates/shopify/schemaTypes/objects/customProductOption/sizeObject.ts b/packages/@sanity/cli/templates/shopify/schemaTypes/objects/customProductOption/customProductOptionSizeObjectType.ts
similarity index 77%
rename from packages/@sanity/cli/templates/shopify/schemaTypes/objects/customProductOption/sizeObject.ts
rename to packages/@sanity/cli/templates/shopify/schemaTypes/objects/customProductOption/customProductOptionSizeObjectType.ts
index a0c81866ac2..94edc961639 100644
--- a/packages/@sanity/cli/templates/shopify/schemaTypes/objects/customProductOption/sizeObject.ts
+++ b/packages/@sanity/cli/templates/shopify/schemaTypes/objects/customProductOption/customProductOptionSizeObjectType.ts
@@ -1,27 +1,24 @@
import {defineField} from 'sanity'
-export default defineField({
+export const customProductOptionSizeObjectType = defineField({
name: 'customProductOption.sizeObject',
title: 'Size',
type: 'object',
fields: [
defineField({
name: 'title',
- title: 'Title',
type: 'string',
description: 'Shopify product option value (case sensitive)',
validation: (Rule) => Rule.required(),
}),
defineField({
name: 'width',
- title: 'Width',
type: 'number',
description: 'In mm',
validation: (Rule) => Rule.required().precision(2),
}),
defineField({
name: 'height',
- title: 'Height',
type: 'number',
description: 'In mm',
validation: (Rule) => Rule.required().precision(2),
@@ -33,10 +30,9 @@ export default defineField({
title: 'title',
width: 'width',
},
- prepare(selection) {
- const {height, title, width} = selection
+ prepare({height, title, width}) {
return {
- subtitle: `${width || '??'}cm x ${height || '??'}cm`,
+ subtitle: `${width || '??'}mm x ${height || '??'}mm`,
title,
}
},
diff --git a/packages/@sanity/cli/templates/shopify/schemaTypes/objects/customProductOption/size.ts b/packages/@sanity/cli/templates/shopify/schemaTypes/objects/customProductOption/customProductOptionSizeType.ts
similarity index 81%
rename from packages/@sanity/cli/templates/shopify/schemaTypes/objects/customProductOption/size.ts
rename to packages/@sanity/cli/templates/shopify/schemaTypes/objects/customProductOption/customProductOptionSizeType.ts
index fc5e40f3d02..5b73e0877a3 100644
--- a/packages/@sanity/cli/templates/shopify/schemaTypes/objects/customProductOption/size.ts
+++ b/packages/@sanity/cli/templates/shopify/schemaTypes/objects/customProductOption/customProductOptionSizeType.ts
@@ -5,30 +5,22 @@ interface SizeOption {
title: string
}
-export default defineField({
+export const customProductOptionSizeType = defineField({
name: 'customProductOption.size',
title: 'Size',
type: 'object',
icon: false,
fields: [
- // Title
defineField({
name: 'title',
- title: 'Title',
type: 'string',
description: 'Shopify product option name (case sensitive)',
validation: (Rule) => Rule.required(),
}),
- // Sizes
defineField({
name: 'sizes',
- title: 'Sizes',
type: 'array',
- of: [
- {
- type: 'customProductOption.sizeObject',
- },
- ],
+ of: [{type: 'customProductOption.sizeObject'}],
validation: (Rule) =>
Rule.custom((options: SizeOption[] | undefined) => {
// Each size must have a unique title
@@ -47,8 +39,7 @@ export default defineField({
sizes: 'sizes',
title: 'title',
},
- prepare(selection) {
- const {sizes, title} = selection
+ prepare({sizes, title}) {
return {
subtitle: sizes.length > 0 ? pluralize('size', sizes.length, true) : 'No sizes',
title,
diff --git a/packages/@sanity/cli/templates/shopify/schemaTypes/objects/global/footer.ts b/packages/@sanity/cli/templates/shopify/schemaTypes/objects/global/footer.ts
deleted file mode 100644
index 8e1e7b0cc86..00000000000
--- a/packages/@sanity/cli/templates/shopify/schemaTypes/objects/global/footer.ts
+++ /dev/null
@@ -1,57 +0,0 @@
-import {defineField} from 'sanity'
-
-export default defineField({
- name: 'footerSettings',
- title: 'Footer',
- type: 'object',
- options: {
- collapsed: false,
- collapsible: true,
- },
- fields: [
- // Links
- defineField({
- name: 'links',
- title: 'Links',
- type: 'array',
- of: [{type: 'linkInternal'}, {type: 'linkExternal'}],
- }),
- // Text
- defineField({
- name: 'text',
- title: 'Text',
- type: 'array',
- of: [
- {
- lists: [],
- marks: {
- annotations: [
- // Email
- {
- title: 'Email',
- name: 'annotationLinkEmail',
- type: 'annotationLinkEmail',
- },
- // Internal link
- {
- title: 'Internal page',
- name: 'annotationLinkInternal',
- type: 'annotationLinkInternal',
- },
- // URL
- {
- title: 'URL',
- name: 'annotationLinkExternal',
- type: 'annotationLinkExternal',
- },
- ],
- decorators: [],
- },
- // Block styles
- styles: [{title: 'Normal', value: 'normal'}],
- type: 'block',
- },
- ],
- }),
- ],
-})
diff --git a/packages/@sanity/cli/templates/shopify/schemaTypes/objects/global/footerType.ts b/packages/@sanity/cli/templates/shopify/schemaTypes/objects/global/footerType.ts
new file mode 100644
index 00000000000..1e107dbbd5f
--- /dev/null
+++ b/packages/@sanity/cli/templates/shopify/schemaTypes/objects/global/footerType.ts
@@ -0,0 +1,22 @@
+import {defineField} from 'sanity'
+
+export const footerType = defineField({
+ name: 'footerSettings',
+ title: 'Footer',
+ type: 'object',
+ options: {
+ collapsed: false,
+ collapsible: true,
+ },
+ fields: [
+ defineField({
+ name: 'links',
+ type: 'array',
+ of: [{type: 'linkInternal'}, {type: 'linkExternal'}],
+ }),
+ defineField({
+ name: 'text',
+ type: 'portableTextSimple',
+ }),
+ ],
+})
diff --git a/packages/@sanity/cli/templates/shopify/schemaTypes/objects/global/linkExternal.ts b/packages/@sanity/cli/templates/shopify/schemaTypes/objects/global/linkExternal.ts
deleted file mode 100644
index 86ab1080001..00000000000
--- a/packages/@sanity/cli/templates/shopify/schemaTypes/objects/global/linkExternal.ts
+++ /dev/null
@@ -1,52 +0,0 @@
-import {EarthGlobeIcon} from '@sanity/icons'
-import {defineField} from 'sanity'
-
-export default defineField({
- title: 'External Link',
- name: 'linkExternal',
- type: 'object',
- icon: EarthGlobeIcon,
- fields: [
- // Title
- {
- title: 'Title',
- name: 'title',
- type: 'string',
- validation: (Rule) => Rule.required(),
- },
- // URL
- {
- name: 'url',
- title: 'URL',
- type: 'url',
- validation: (Rule) => Rule.required().uri({scheme: ['http', 'https']}),
- },
- // Open in a new window
- {
- title: 'Open in a new window?',
- name: 'newWindow',
- type: 'boolean',
- initialValue: true,
- },
- ],
- preview: {
- select: {
- title: 'title',
- url: 'url',
- },
- prepare(selection) {
- const {title, url} = selection
-
- let subtitle = []
- if (url) {
- subtitle.push(`→ ${url}`)
- }
-
- return {
- // media: image,
- subtitle: subtitle.join(' '),
- title,
- }
- },
- },
-})
diff --git a/packages/@sanity/cli/templates/shopify/schemaTypes/objects/global/linkInternal.ts b/packages/@sanity/cli/templates/shopify/schemaTypes/objects/global/linkInternal.ts
deleted file mode 100644
index 244f694bcd2..00000000000
--- a/packages/@sanity/cli/templates/shopify/schemaTypes/objects/global/linkInternal.ts
+++ /dev/null
@@ -1,65 +0,0 @@
-import {LinkIcon} from '@sanity/icons'
-import {defineField} from 'sanity'
-
-import {PAGE_REFERENCES} from '../../../constants'
-import {getPriceRange} from '../../../utils/getPriceRange'
-
-export default defineField({
- title: 'Internal Link',
- name: 'linkInternal',
- type: 'object',
- icon: LinkIcon,
- fields: [
- // Title
- {
- title: 'Title',
- name: 'title',
- type: 'string',
- validation: (Rule) => Rule.required(),
- },
- // Reference
- {
- name: 'reference',
- type: 'reference',
- weak: true,
- validation: (Rule) => Rule.required(),
- to: PAGE_REFERENCES,
- },
- ],
- preview: {
- select: {
- reference: 'reference',
- referenceProductTitle: 'reference.store.title',
- referenceProductPriceRange: 'reference.store.priceRange',
- referenceTitle: 'reference.title',
- referenceType: 'reference._type',
- title: 'title',
- },
- prepare(selection) {
- const {
- reference,
- referenceProductPriceRange,
- referenceProductTitle,
- referenceTitle,
- referenceType,
- title,
- } = selection
-
- let subtitle = []
- if (reference) {
- subtitle.push([`→ ${referenceTitle || referenceProductTitle || reference?._id}`])
- if (referenceType === 'product' && referenceProductPriceRange) {
- subtitle.push(`(${getPriceRange(referenceProductPriceRange)})`)
- }
- } else {
- subtitle.push('(Nonexistent document reference)')
- }
-
- return {
- // media: image,
- subtitle: subtitle.join(' '),
- title,
- }
- },
- },
-})
diff --git a/packages/@sanity/cli/templates/shopify/schemaTypes/objects/global/links.ts b/packages/@sanity/cli/templates/shopify/schemaTypes/objects/global/links.ts
deleted file mode 100644
index fe912fa5065..00000000000
--- a/packages/@sanity/cli/templates/shopify/schemaTypes/objects/global/links.ts
+++ /dev/null
@@ -1,16 +0,0 @@
-import {defineField} from 'sanity'
-
-export default defineField({
- name: 'menuLinks',
- title: 'menuLinks',
- type: 'array',
- of: [
- {
- name: 'collectionGroup',
- title: 'Collection group',
- type: 'collectionGroup',
- },
- {type: 'linkInternal'},
- {type: 'linkExternal'},
- ],
-})
diff --git a/packages/@sanity/cli/templates/shopify/schemaTypes/objects/global/menuLinksType.ts b/packages/@sanity/cli/templates/shopify/schemaTypes/objects/global/menuLinksType.ts
new file mode 100644
index 00000000000..4b22d963a7f
--- /dev/null
+++ b/packages/@sanity/cli/templates/shopify/schemaTypes/objects/global/menuLinksType.ts
@@ -0,0 +1,21 @@
+import {defineField} from 'sanity'
+
+export const menuLinksType = defineField({
+ name: 'menuLinks',
+ title: 'Menu Links',
+ type: 'array',
+ of: [
+ defineField({
+ name: 'collectionGroup',
+ type: 'collectionGroup',
+ }),
+ defineField({
+ name: 'linkInternal',
+ type: 'linkInternal',
+ }),
+ defineField({
+ name: 'linkExternal',
+ type: 'linkExternal',
+ }),
+ ],
+})
diff --git a/packages/@sanity/cli/templates/shopify/schemaTypes/objects/global/menu.ts b/packages/@sanity/cli/templates/shopify/schemaTypes/objects/global/menuType.ts
similarity index 71%
rename from packages/@sanity/cli/templates/shopify/schemaTypes/objects/global/menu.ts
rename to packages/@sanity/cli/templates/shopify/schemaTypes/objects/global/menuType.ts
index 28d3ae042e3..6c24b2544b3 100644
--- a/packages/@sanity/cli/templates/shopify/schemaTypes/objects/global/menu.ts
+++ b/packages/@sanity/cli/templates/shopify/schemaTypes/objects/global/menuType.ts
@@ -1,7 +1,7 @@
import {defineField} from 'sanity'
-export default defineField({
- name: 'menuSettings',
+export const menuType = defineField({
+ name: 'menu',
title: 'Menu',
type: 'object',
options: {
@@ -9,10 +9,8 @@ export default defineField({
collapsible: true,
},
fields: [
- // Links
defineField({
name: 'links',
- title: 'Links',
type: 'menuLinks',
}),
],
diff --git a/packages/@sanity/cli/templates/shopify/schemaTypes/objects/global/notFoundPage.ts b/packages/@sanity/cli/templates/shopify/schemaTypes/objects/global/notFoundPageType.ts
similarity index 82%
rename from packages/@sanity/cli/templates/shopify/schemaTypes/objects/global/notFoundPage.ts
rename to packages/@sanity/cli/templates/shopify/schemaTypes/objects/global/notFoundPageType.ts
index 59b502693ad..25f3c0857ba 100644
--- a/packages/@sanity/cli/templates/shopify/schemaTypes/objects/global/notFoundPage.ts
+++ b/packages/@sanity/cli/templates/shopify/schemaTypes/objects/global/notFoundPageType.ts
@@ -1,6 +1,6 @@
import {defineField} from 'sanity'
-export default defineField({
+export const notFoundPageType = defineField({
name: 'notFoundPage',
title: '404 page',
type: 'object',
@@ -8,19 +8,16 @@ export default defineField({
fields: [
defineField({
name: 'title',
- title: 'Title',
type: 'string',
validation: (Rule) => Rule.required(),
}),
defineField({
name: 'body',
- title: 'Body',
type: 'text',
rows: 2,
}),
defineField({
name: 'collection',
- title: 'Collection',
type: 'reference',
description: 'Collection products displayed on this page',
weak: true,
@@ -31,10 +28,8 @@ export default defineField({
},
],
}),
- // Color theme
defineField({
name: 'colorTheme',
- title: 'Color theme',
type: 'reference',
to: [{type: 'colorTheme'}],
}),
diff --git a/packages/@sanity/cli/templates/shopify/schemaTypes/objects/hero/collection.tsx b/packages/@sanity/cli/templates/shopify/schemaTypes/objects/hero/collection.tsx
deleted file mode 100644
index b54e77067c8..00000000000
--- a/packages/@sanity/cli/templates/shopify/schemaTypes/objects/hero/collection.tsx
+++ /dev/null
@@ -1,42 +0,0 @@
-import {defineField} from 'sanity'
-
-export default defineField({
- name: 'hero.collection',
- title: 'Collection hero',
- type: 'object',
- fields: [
- // Title
- defineField({
- name: 'title',
- title: 'Title',
- type: 'text',
- rows: 3,
- }),
- // Description
- defineField({
- name: 'description',
- title: 'Description',
- type: 'text',
- rows: 3,
- }),
- // Content
- defineField({
- name: 'content',
- title: 'Content',
- type: 'array',
- validation: (Rule) => Rule.max(1),
- of: [
- {
- name: 'productWithVariant',
- title: 'Product with variant',
- type: 'productWithVariant',
- },
- {
- name: 'imageWithProductHotspots',
- title: 'Image',
- type: 'imageWithProductHotspots',
- },
- ],
- }),
- ],
-})
diff --git a/packages/@sanity/cli/templates/shopify/schemaTypes/objects/hero/page.tsx b/packages/@sanity/cli/templates/shopify/schemaTypes/objects/hero/page.tsx
deleted file mode 100644
index 184cbdf11de..00000000000
--- a/packages/@sanity/cli/templates/shopify/schemaTypes/objects/hero/page.tsx
+++ /dev/null
@@ -1,35 +0,0 @@
-import {defineField} from 'sanity'
-
-export default defineField({
- name: 'hero.page',
- title: 'Page hero',
- type: 'object',
- fields: [
- // Title
- defineField({
- name: 'title',
- title: 'Title',
- type: 'text',
- rows: 3,
- }),
- // Content
- defineField({
- name: 'content',
- title: 'Content',
- type: 'array',
- validation: (Rule) => Rule.max(1),
- of: [
- {
- name: 'productWithVariant',
- title: 'Product with variant',
- type: 'productWithVariant',
- },
- {
- name: 'imageWithProductHotspots',
- title: 'Image',
- type: 'imageWithProductHotspots',
- },
- ],
- }),
- ],
-})
diff --git a/packages/@sanity/cli/templates/shopify/schemaTypes/objects/hotspot/imageWithProductHotspots.ts b/packages/@sanity/cli/templates/shopify/schemaTypes/objects/hotspot/imageWithProductHotspotsType.ts
similarity index 80%
rename from packages/@sanity/cli/templates/shopify/schemaTypes/objects/hotspot/imageWithProductHotspots.ts
rename to packages/@sanity/cli/templates/shopify/schemaTypes/objects/hotspot/imageWithProductHotspotsType.ts
index b5190993a21..17782d2aea3 100644
--- a/packages/@sanity/cli/templates/shopify/schemaTypes/objects/hotspot/imageWithProductHotspots.ts
+++ b/packages/@sanity/cli/templates/shopify/schemaTypes/objects/hotspot/imageWithProductHotspotsType.ts
@@ -2,7 +2,7 @@ import {ImageIcon} from '@sanity/icons'
import pluralize from 'pluralize-esm'
import {defineField} from 'sanity'
-export default defineField({
+export const imageWithProductHotspotsType = defineField({
icon: ImageIcon,
name: 'imageWithProductHotspots',
title: 'Image',
@@ -10,20 +10,19 @@ export default defineField({
fields: [
defineField({
name: 'image',
- title: 'Image',
options: {hotspot: true},
type: 'image',
validation: (Rule) => Rule.required(),
+ // Hide original image when showHotspots is true and an image is set
+ hidden: ({value, parent}) => parent.showHotspots && value,
}),
defineField({
name: 'showHotspots',
- title: 'Show product hotspots',
type: 'boolean',
initialValue: false,
}),
defineField({
name: 'productHotspots',
- title: 'Product hotspots',
type: 'productHotspots',
hidden: ({parent}) => !parent.showHotspots,
}),
@@ -35,8 +34,7 @@ export default defineField({
image: 'image',
showHotspots: 'showHotspots',
},
- prepare(selection) {
- const {fileName, hotspots, image, showHotspots} = selection
+ prepare({fileName, hotspots, image, showHotspots}) {
return {
media: image,
subtitle:
diff --git a/packages/@sanity/cli/templates/shopify/schemaTypes/objects/hotspot/productHotspots.tsx b/packages/@sanity/cli/templates/shopify/schemaTypes/objects/hotspot/productHotspotsType.tsx
similarity index 66%
rename from packages/@sanity/cli/templates/shopify/schemaTypes/objects/hotspot/productHotspots.tsx
rename to packages/@sanity/cli/templates/shopify/schemaTypes/objects/hotspot/productHotspotsType.tsx
index 4147e093e8f..22f3fdded89 100644
--- a/packages/@sanity/cli/templates/shopify/schemaTypes/objects/hotspot/productHotspots.tsx
+++ b/packages/@sanity/cli/templates/shopify/schemaTypes/objects/hotspot/productHotspotsType.tsx
@@ -1,15 +1,13 @@
-import {defineField} from 'sanity'
+import {defineArrayMember, defineField} from 'sanity'
import ProductTooltip from '../../../components/hotspots/ProductTooltip'
-export default defineField({
+export const productHotspotsType = defineField({
name: 'productHotspots',
title: 'Hotspots',
type: 'array',
of: [
- {
- type: 'spot',
- },
+ defineArrayMember({type: 'spot'}),
],
options: {
imageHotspot: {
diff --git a/packages/@sanity/cli/templates/shopify/schemaTypes/objects/hotspot/spot.tsx b/packages/@sanity/cli/templates/shopify/schemaTypes/objects/hotspot/spotType.tsx
similarity index 94%
rename from packages/@sanity/cli/templates/shopify/schemaTypes/objects/hotspot/spot.tsx
rename to packages/@sanity/cli/templates/shopify/schemaTypes/objects/hotspot/spotType.tsx
index 54fd0b60aec..97a94f65604 100644
--- a/packages/@sanity/cli/templates/shopify/schemaTypes/objects/hotspot/spot.tsx
+++ b/packages/@sanity/cli/templates/shopify/schemaTypes/objects/hotspot/spotType.tsx
@@ -1,9 +1,8 @@
-import React from 'react'
import {defineField} from 'sanity'
import ShopifyDocumentStatus from '../../../components/media/ShopifyDocumentStatus'
-export default defineField({
+export const spotType = defineField({
name: 'spot',
title: 'Spot',
type: 'object',
@@ -11,7 +10,6 @@ export default defineField({
fields: [
defineField({
name: 'productWithVariant',
- title: 'Product + Variant',
type: 'productWithVariant',
}),
defineField({
diff --git a/packages/@sanity/cli/templates/shopify/schemaTypes/annotations/linkEmail.tsx b/packages/@sanity/cli/templates/shopify/schemaTypes/objects/link/linkEmailType.tsx
similarity index 63%
rename from packages/@sanity/cli/templates/shopify/schemaTypes/annotations/linkEmail.tsx
rename to packages/@sanity/cli/templates/shopify/schemaTypes/objects/link/linkEmailType.tsx
index e33385abf2b..df8b0b10782 100644
--- a/packages/@sanity/cli/templates/shopify/schemaTypes/annotations/linkEmail.tsx
+++ b/packages/@sanity/cli/templates/shopify/schemaTypes/objects/link/linkEmailType.tsx
@@ -1,15 +1,9 @@
-/**
- * Annotations are ways of marking up text in the block content editor.
- *
- * Read more: https://www.sanity.io/docs/customization#f924645007e1
- */
import {EnvelopeIcon} from '@sanity/icons'
-import React from 'react'
import {defineField} from 'sanity'
-export default defineField({
+export const linkEmailType = defineField({
title: 'Email link',
- name: 'annotationLinkEmail',
+ name: 'linkEmail',
type: 'object',
icon: EnvelopeIcon,
components: {
@@ -27,16 +21,14 @@ export default defineField({
),
},
fields: [
- // Email
- {
- title: 'Email',
+ defineField({
name: 'email',
type: 'email',
- },
+ }),
],
preview: {
select: {
- email: 'email',
+ title: 'email',
},
},
})
diff --git a/packages/@sanity/cli/templates/shopify/schemaTypes/annotations/linkExternal.tsx b/packages/@sanity/cli/templates/shopify/schemaTypes/objects/link/linkExternalType.tsx
similarity index 70%
rename from packages/@sanity/cli/templates/shopify/schemaTypes/annotations/linkExternal.tsx
rename to packages/@sanity/cli/templates/shopify/schemaTypes/objects/link/linkExternalType.tsx
index 5d1479f2dfd..c87fac70d25 100644
--- a/packages/@sanity/cli/templates/shopify/schemaTypes/annotations/linkExternal.tsx
+++ b/packages/@sanity/cli/templates/shopify/schemaTypes/objects/link/linkExternalType.tsx
@@ -1,15 +1,9 @@
-/**
- * Annotations are ways of marking up text in the block content editor.
- *
- * Read more: https://www.sanity.io/docs/customization#f924645007e1
- */
import {EarthGlobeIcon} from '@sanity/icons'
-import React from 'react'
import {defineField} from 'sanity'
-export default defineField({
+export const linkExternalType = defineField({
title: 'External Link',
- name: 'annotationLinkExternal',
+ name: 'linkExternal',
type: 'object',
icon: EarthGlobeIcon,
components: {
@@ -27,18 +21,17 @@ export default defineField({
),
},
fields: [
- {
+ defineField({
name: 'url',
title: 'URL',
type: 'url',
validation: (Rule) => Rule.required().uri({scheme: ['http', 'https']}),
- },
- // Open in a new window
- {
+ }),
+ defineField({
title: 'Open in a new window?',
name: 'newWindow',
type: 'boolean',
initialValue: true,
- },
+ }),
],
})
diff --git a/packages/@sanity/cli/templates/shopify/schemaTypes/annotations/linkInternal.tsx b/packages/@sanity/cli/templates/shopify/schemaTypes/objects/link/linkInternalType.tsx
similarity index 64%
rename from packages/@sanity/cli/templates/shopify/schemaTypes/annotations/linkInternal.tsx
rename to packages/@sanity/cli/templates/shopify/schemaTypes/objects/link/linkInternalType.tsx
index 46fe8417b4a..3379b7a6b9e 100644
--- a/packages/@sanity/cli/templates/shopify/schemaTypes/annotations/linkInternal.tsx
+++ b/packages/@sanity/cli/templates/shopify/schemaTypes/objects/link/linkInternalType.tsx
@@ -1,16 +1,10 @@
-/**
- * Annotations are ways of marking up text in the block content editor.
- *
- * Read more: https://www.sanity.io/docs/customization#f924645007e1
- */
import {LinkIcon} from '@sanity/icons'
-import React from 'react'
import {defineField} from 'sanity'
-import {PAGE_REFERENCES} from '../../constants'
+import {PAGE_REFERENCES} from '../../../constants'
-export default defineField({
+export const linkInternalType = defineField({
title: 'Internal Link',
- name: 'annotationLinkInternal',
+ name: 'linkInternal',
type: 'object',
icon: LinkIcon,
components: {
@@ -28,13 +22,12 @@ export default defineField({
),
},
fields: [
- // Reference
- {
+ defineField({
name: 'reference',
type: 'reference',
weak: true,
validation: (Rule) => Rule.required(),
to: PAGE_REFERENCES,
- },
+ }),
],
})
diff --git a/packages/@sanity/cli/templates/shopify/schemaTypes/annotations/product.tsx b/packages/@sanity/cli/templates/shopify/schemaTypes/objects/link/linkProductType.tsx
similarity index 76%
rename from packages/@sanity/cli/templates/shopify/schemaTypes/annotations/product.tsx
rename to packages/@sanity/cli/templates/shopify/schemaTypes/objects/link/linkProductType.tsx
index 9044dd12d16..633d314cf78 100644
--- a/packages/@sanity/cli/templates/shopify/schemaTypes/annotations/product.tsx
+++ b/packages/@sanity/cli/templates/shopify/schemaTypes/objects/link/linkProductType.tsx
@@ -1,15 +1,9 @@
-/**
- * Annotations are ways of marking up text in the block content editor.
- *
- * Read more: https://www.sanity.io/docs/customization#f924645007e1
- */
import {TagIcon} from '@sanity/icons'
-import React from 'react'
import {defineField} from 'sanity'
-export default defineField({
+export const linkProductType = defineField({
title: 'Product',
- name: 'annotationProduct',
+ name: 'linkProduct',
type: 'object',
icon: TagIcon,
components: {
@@ -27,17 +21,13 @@ export default defineField({
),
},
fields: [
- // Product
- {
+ defineField({
name: 'productWithVariant',
- title: 'Product + Variant',
type: 'productWithVariant',
validation: (Rule) => Rule.required(),
- },
- // Link action
+ }),
defineField({
name: 'linkAction',
- title: 'Link action',
type: 'string',
initialValue: 'link',
options: {
@@ -59,10 +49,8 @@ export default defineField({
},
validation: (Rule) => Rule.required(),
}),
- // Quantity
defineField({
name: 'quantity',
- title: 'Quantity',
type: 'number',
initialValue: 1,
hidden: ({parent}) => parent.linkAction === 'link',
diff --git a/packages/@sanity/cli/templates/shopify/schemaTypes/objects/module/accordionBody.ts b/packages/@sanity/cli/templates/shopify/schemaTypes/objects/module/accordionBody.ts
deleted file mode 100644
index 272c683a308..00000000000
--- a/packages/@sanity/cli/templates/shopify/schemaTypes/objects/module/accordionBody.ts
+++ /dev/null
@@ -1,45 +0,0 @@
-import {defineField} from 'sanity'
-
-export default defineField({
- name: 'accordionBody',
- title: 'Body',
- type: 'array',
- of: [
- {
- lists: [],
- marks: {
- annotations: [
- // 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',
- },
- ],
-})
diff --git a/packages/@sanity/cli/templates/shopify/schemaTypes/objects/module/accordionGroup.ts b/packages/@sanity/cli/templates/shopify/schemaTypes/objects/module/accordionGroupType.ts
similarity index 74%
rename from packages/@sanity/cli/templates/shopify/schemaTypes/objects/module/accordionGroup.ts
rename to packages/@sanity/cli/templates/shopify/schemaTypes/objects/module/accordionGroupType.ts
index 35681bb0169..83bed30d867 100644
--- a/packages/@sanity/cli/templates/shopify/schemaTypes/objects/module/accordionGroup.ts
+++ b/packages/@sanity/cli/templates/shopify/schemaTypes/objects/module/accordionGroupType.ts
@@ -1,35 +1,32 @@
import {defineField} from 'sanity'
import blocksToText from '../../../utils/blocksToText'
-export default defineField({
+export const accordionGroupType = defineField({
name: 'accordionGroup',
- title: 'Object',
+ title: 'Accordion Group',
type: 'object',
icon: false,
fields: [
defineField({
name: 'title',
- title: 'Title',
type: 'string',
validation: (Rule) => Rule.required(),
}),
defineField({
name: 'body',
- title: 'Body',
- type: 'accordionBody',
+ type: 'portableTextSimple',
validation: (Rule) => Rule.required(),
}),
],
preview: {
select: {
- body: 'body',
title: 'title',
+ body: 'body',
},
- prepare(selection) {
- const {body, title} = selection
+ prepare({title, body}) {
return {
- subtitle: body && blocksToText(body),
title,
+ subtitle: body && blocksToText(body),
}
},
},
diff --git a/packages/@sanity/cli/templates/shopify/schemaTypes/objects/module/accordion.ts b/packages/@sanity/cli/templates/shopify/schemaTypes/objects/module/accordionType.ts
similarity index 68%
rename from packages/@sanity/cli/templates/shopify/schemaTypes/objects/module/accordion.ts
rename to packages/@sanity/cli/templates/shopify/schemaTypes/objects/module/accordionType.ts
index 838fecccb6f..02119ab2df2 100644
--- a/packages/@sanity/cli/templates/shopify/schemaTypes/objects/module/accordion.ts
+++ b/packages/@sanity/cli/templates/shopify/schemaTypes/objects/module/accordionType.ts
@@ -2,30 +2,23 @@ import {StackCompactIcon} from '@sanity/icons'
import pluralize from 'pluralize-esm'
import {defineField} from 'sanity'
-export default defineField({
- name: 'module.accordion',
+export const accordionType = defineField({
+ name: 'accordion',
title: 'Accordion',
type: 'object',
icon: StackCompactIcon,
fields: [
- // Groups
defineField({
name: 'groups',
- title: 'Groups',
type: 'array',
- of: [
- {
- type: 'accordionGroup',
- },
- ],
+ of: [{type: 'accordionGroup'}],
}),
],
preview: {
select: {
groups: 'groups',
},
- prepare(selection) {
- const {groups} = selection
+ prepare({groups}) {
return {
subtitle: 'Accordion',
title: groups?.length > 0 ? pluralize('group', groups.length, true) : 'No groups',
diff --git a/packages/@sanity/cli/templates/shopify/schemaTypes/objects/module/callToAction.tsx b/packages/@sanity/cli/templates/shopify/schemaTypes/objects/module/callToActionType.tsx
similarity index 76%
rename from packages/@sanity/cli/templates/shopify/schemaTypes/objects/module/callToAction.tsx
rename to packages/@sanity/cli/templates/shopify/schemaTypes/objects/module/callToActionType.tsx
index 7a20f62d7e8..51595982609 100644
--- a/packages/@sanity/cli/templates/shopify/schemaTypes/objects/module/callToAction.tsx
+++ b/packages/@sanity/cli/templates/shopify/schemaTypes/objects/module/callToActionType.tsx
@@ -1,8 +1,8 @@
import {BlockElementIcon, ImageIcon} from '@sanity/icons'
-import {defineField} from 'sanity'
+import {defineArrayMember, defineField} from 'sanity'
-export default defineField({
- name: 'module.callToAction',
+export const callToActionType = defineField({
+ name: 'callToAction',
title: 'Call to action',
type: 'object',
icon: BlockElementIcon,
@@ -13,10 +13,8 @@ export default defineField({
},
],
fields: [
- // Layout
defineField({
name: 'layout',
- title: 'Layout direction',
type: 'string',
initialValue: 'left',
options: {
@@ -35,50 +33,40 @@ export default defineField({
},
validation: (Rule) => Rule.required(),
}),
- // Title
defineField({
name: 'title',
- title: 'Title',
type: 'string',
validation: (Rule) => Rule.required(),
fieldset: 'copy',
}),
- // Body
defineField({
- name: 'body',
- title: 'Body',
+ name: 'portableText',
type: 'text',
rows: 2,
fieldset: 'copy',
}),
- // Link
defineField({
- name: 'links',
- title: 'Link',
+ name: 'link',
type: 'array',
of: [{type: 'linkInternal'}, {type: 'linkExternal'}],
validation: (Rule) => Rule.max(1),
fieldset: 'copy',
}),
- // Content
defineField({
name: 'content',
- title: 'Content',
type: 'array',
validation: (Rule) => Rule.required().max(1),
of: [
- {
+ defineArrayMember({
icon: ImageIcon,
type: 'image',
- title: 'Image',
options: {hotspot: true},
- },
- {
+ }),
+ defineArrayMember({
name: 'productWithVariant',
- title: 'Product + Variant',
type: 'productWithVariant',
validation: (Rule) => Rule.required(),
- },
+ }),
],
}),
],
@@ -86,8 +74,7 @@ export default defineField({
select: {
title: 'title',
},
- prepare(selection) {
- const {title} = selection
+ prepare({title}) {
return {
subtitle: 'Call to action',
title,
diff --git a/packages/@sanity/cli/templates/shopify/schemaTypes/objects/module/callout.ts b/packages/@sanity/cli/templates/shopify/schemaTypes/objects/module/calloutType.ts
similarity index 76%
rename from packages/@sanity/cli/templates/shopify/schemaTypes/objects/module/callout.ts
rename to packages/@sanity/cli/templates/shopify/schemaTypes/objects/module/calloutType.ts
index 7ae57ec8fc7..f5459713591 100644
--- a/packages/@sanity/cli/templates/shopify/schemaTypes/objects/module/callout.ts
+++ b/packages/@sanity/cli/templates/shopify/schemaTypes/objects/module/calloutType.ts
@@ -1,16 +1,14 @@
import {BulbOutlineIcon} from '@sanity/icons'
import {defineField} from 'sanity'
-export default defineField({
- name: 'module.callout',
+export const calloutType = defineField({
+ name: 'callout',
title: 'Callout',
type: 'object',
icon: BulbOutlineIcon,
fields: [
- // Text
defineField({
name: 'text',
- title: 'Text',
type: 'text',
rows: 2,
validation: (Rule) => [
@@ -18,10 +16,8 @@ export default defineField({
Rule.max(70).warning(`Callout length shouldn't be more than 70 characters.`),
],
}),
- // Link
defineField({
- name: 'links',
- title: 'Link',
+ name: 'link',
type: 'array',
of: [{type: 'linkInternal'}, {type: 'linkExternal'}],
validation: (Rule) => Rule.max(1),
@@ -30,10 +26,8 @@ export default defineField({
preview: {
select: {
text: 'text',
- url: 'url',
},
- prepare(selection) {
- const {text, url} = selection
+ prepare({text}) {
return {
subtitle: 'Callout',
title: text,
diff --git a/packages/@sanity/cli/templates/shopify/schemaTypes/objects/module/collection.tsx b/packages/@sanity/cli/templates/shopify/schemaTypes/objects/module/collectionReferenceType.tsx
similarity index 79%
rename from packages/@sanity/cli/templates/shopify/schemaTypes/objects/module/collection.tsx
rename to packages/@sanity/cli/templates/shopify/schemaTypes/objects/module/collectionReferenceType.tsx
index 7f0e5b3931c..891ad2eda14 100644
--- a/packages/@sanity/cli/templates/shopify/schemaTypes/objects/module/collection.tsx
+++ b/packages/@sanity/cli/templates/shopify/schemaTypes/objects/module/collectionReferenceType.tsx
@@ -1,28 +1,24 @@
-import React from 'react'
+
import {PackageIcon} from '@sanity/icons'
import {defineField} from 'sanity'
import ShopifyDocumentStatus from '../../../components/media/ShopifyDocumentStatus'
-export default defineField({
- name: 'module.collection',
+export const collectionReferenceType = defineField({
+ name: 'collectionReference',
title: 'Collection',
type: 'object',
icon: PackageIcon,
fields: [
- // Collection
defineField({
name: 'collection',
- title: 'Collection',
type: 'reference',
weak: true,
to: [{type: 'collection'}],
validation: (Rule) => Rule.required(),
}),
- // Show background
defineField({
name: 'showBackground',
- title: 'Show background',
type: 'boolean',
description: 'Use Shopify collection image as background (if available)',
initialValue: false,
@@ -34,8 +30,7 @@ export default defineField({
imageUrl: 'collection.store.imageUrl',
isDeleted: 'collection.store.isDeleted',
},
- prepare(selection) {
- const {collectionTitle, imageUrl, isDeleted} = selection
+ prepare({collectionTitle, imageUrl, isDeleted}) {
return {
media: (
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,
- }
- },
- },
-})
diff --git a/packages/@sanity/cli/templates/shopify/schemaTypes/objects/module/gridItemType.ts b/packages/@sanity/cli/templates/shopify/schemaTypes/objects/module/gridItemType.ts
new file mode 100644
index 00000000000..ef2cb9c6951
--- /dev/null
+++ b/packages/@sanity/cli/templates/shopify/schemaTypes/objects/module/gridItemType.ts
@@ -0,0 +1,41 @@
+import {defineField} from 'sanity'
+
+import blocksToText from '../../../utils/blocksToText'
+
+export const gridItemType = defineField({
+ name: 'gridItem',
+ title: 'Grid Item',
+ type: 'object',
+ fields: [
+ defineField({
+ name: 'title',
+ type: 'string',
+ validation: (Rule) => Rule.required(),
+ }),
+ defineField({
+ name: 'image',
+ type: 'image',
+ options: {hotspot: true},
+ validation: (Rule) => Rule.required(),
+ }),
+ defineField({
+ name: 'body',
+ type: 'portableTextSimple',
+ validation: (Rule) => Rule.required(),
+ }),
+ ],
+ preview: {
+ select: {
+ body: 'body',
+ image: 'image',
+ title: 'title',
+ },
+ prepare({body, image, title}) {
+ return {
+ media: image,
+ subtitle: body && blocksToText(body),
+ title,
+ }
+ },
+ },
+})
diff --git a/packages/@sanity/cli/templates/shopify/schemaTypes/objects/module/grid.ts b/packages/@sanity/cli/templates/shopify/schemaTypes/objects/module/gridType.ts
similarity index 59%
rename from packages/@sanity/cli/templates/shopify/schemaTypes/objects/module/grid.ts
rename to packages/@sanity/cli/templates/shopify/schemaTypes/objects/module/gridType.ts
index 45f5d980a1c..6c40e683d4c 100644
--- a/packages/@sanity/cli/templates/shopify/schemaTypes/objects/module/grid.ts
+++ b/packages/@sanity/cli/templates/shopify/schemaTypes/objects/module/gridType.ts
@@ -1,32 +1,24 @@
import {ThLargeIcon} from '@sanity/icons'
import pluralize from 'pluralize-esm'
-import {defineField} from 'sanity'
+import {defineArrayMember, defineField} from 'sanity'
-export default defineField({
- name: 'module.grid',
+export const gridType = defineField({
+ name: 'grid',
title: 'Grid',
type: 'object',
icon: ThLargeIcon,
fields: [
- // Items
- {
+ defineField({
name: 'items',
- title: 'Items',
type: 'array',
- of: [
- {
- type: 'gridItem',
- },
- ],
- },
+ of: [defineArrayMember({type: 'gridItem'})],
+ }),
],
preview: {
select: {
items: 'items',
- url: 'url',
},
- prepare(selection) {
- const {items} = selection
+ prepare({items}) {
return {
subtitle: 'Grid',
title: items?.length > 0 ? pluralize('item', items.length, true) : 'No items',
diff --git a/packages/@sanity/cli/templates/shopify/schemaTypes/objects/hero/home.tsx b/packages/@sanity/cli/templates/shopify/schemaTypes/objects/module/heroType.tsx
similarity index 62%
rename from packages/@sanity/cli/templates/shopify/schemaTypes/objects/hero/home.tsx
rename to packages/@sanity/cli/templates/shopify/schemaTypes/objects/module/heroType.tsx
index 8a43c3b3f95..8fb5ce59f6d 100644
--- a/packages/@sanity/cli/templates/shopify/schemaTypes/objects/hero/home.tsx
+++ b/packages/@sanity/cli/templates/shopify/schemaTypes/objects/module/heroType.tsx
@@ -1,42 +1,39 @@
-import {defineField} from 'sanity'
+import {defineArrayMember, defineField} from 'sanity'
-export default defineField({
- name: 'hero.home',
- title: 'Home hero',
+export const heroType = defineField({
+ name: 'hero',
+ title: 'Hero',
type: 'object',
fields: [
- // Title
defineField({
name: 'title',
- title: 'Title',
type: 'text',
rows: 3,
}),
- // Link
defineField({
- name: 'links',
- title: 'Link',
+ name: 'description',
+ type: 'text',
+ rows: 3,
+ }),
+ defineField({
+ name: 'link',
type: 'array',
of: [{type: 'linkInternal'}, {type: 'linkExternal'}],
validation: (Rule) => Rule.max(1),
}),
- // Content
defineField({
name: 'content',
- title: 'Content',
type: 'array',
validation: (Rule) => Rule.max(1),
of: [
- {
+ defineArrayMember({
name: 'productWithVariant',
- title: 'Product with variant',
type: 'productWithVariant',
- },
- {
+ }),
+ defineArrayMember({
name: 'imageWithProductHotspots',
- title: 'Image',
type: 'imageWithProductHotspots',
- },
+ }),
],
}),
],
diff --git a/packages/@sanity/cli/templates/shopify/schemaTypes/objects/module/imageCallToAction.tsx b/packages/@sanity/cli/templates/shopify/schemaTypes/objects/module/imageCallToActionType.tsx
similarity index 67%
rename from packages/@sanity/cli/templates/shopify/schemaTypes/objects/module/imageCallToAction.tsx
rename to packages/@sanity/cli/templates/shopify/schemaTypes/objects/module/imageCallToActionType.tsx
index f412eb29a8c..70f126a5f22 100644
--- a/packages/@sanity/cli/templates/shopify/schemaTypes/objects/module/imageCallToAction.tsx
+++ b/packages/@sanity/cli/templates/shopify/schemaTypes/objects/module/imageCallToActionType.tsx
@@ -1,23 +1,19 @@
import {defineField} from 'sanity'
-export default defineField({
+export const imageCallToActionType = defineField({
name: 'imageCallToAction',
title: 'Call to action',
type: 'object',
fields: [
- // Title
- {
+ defineField({
name: 'title',
- title: 'Title',
type: 'string',
- },
- // Link
- {
- name: 'links',
- title: 'Link',
+ }),
+ defineField({
+ name: 'link',
type: 'array',
of: [{type: 'linkInternal'}, {type: 'linkExternal'}],
validation: (Rule) => Rule.max(1),
- },
+ }),
],
})
diff --git a/packages/@sanity/cli/templates/shopify/schemaTypes/objects/module/image.ts b/packages/@sanity/cli/templates/shopify/schemaTypes/objects/module/imageFeatureType.ts
similarity index 81%
rename from packages/@sanity/cli/templates/shopify/schemaTypes/objects/module/image.ts
rename to packages/@sanity/cli/templates/shopify/schemaTypes/objects/module/imageFeatureType.ts
index 3af59de8099..ddf23c8d055 100644
--- a/packages/@sanity/cli/templates/shopify/schemaTypes/objects/module/image.ts
+++ b/packages/@sanity/cli/templates/shopify/schemaTypes/objects/module/imageFeatureType.ts
@@ -9,24 +9,20 @@ const VARIANTS = [
{title: 'Product tags', value: 'productTags'},
]
-export default defineField({
- name: 'module.image',
- title: 'Image',
+export const imageFeatureType = defineField({
+ name: 'imageFeature',
+ title: 'Image Feature',
type: 'object',
icon: ImageIcon,
fields: [
- // Image
defineField({
name: 'image',
- title: 'Image',
type: 'image',
options: {hotspot: true},
validation: (Rule) => Rule.required(),
}),
- // Variant
defineField({
name: 'variant',
- title: 'Variant',
type: 'string',
options: {
direction: 'horizontal',
@@ -35,40 +31,33 @@ export default defineField({
},
initialValue: undefined,
}),
- // Caption
defineField({
name: 'caption',
- title: 'Caption',
type: 'text',
rows: 2,
hidden: ({parent}) => parent.variant !== 'caption',
}),
- // Call to action
defineField({
name: 'callToAction',
- title: 'Call to action',
type: 'imageCallToAction',
hidden: ({parent}) => parent.variant !== 'callToAction',
}),
- // Product hotspots
defineField({
name: 'productHotspots',
title: 'Hotspots',
type: 'productHotspots',
hidden: ({parent}) => parent.variant !== 'productHotspots',
}),
- // Product tags
defineField({
name: 'productTags',
title: 'Products',
type: 'array',
hidden: ({parent}) => parent.variant !== 'productTags',
of: [
- {
+ defineField({
name: 'productWithVariant',
- title: 'Product + Variant',
type: 'productWithVariant',
- },
+ }),
],
}),
],
@@ -78,8 +67,7 @@ export default defineField({
image: 'image',
variant: 'variant',
},
- prepare(selection) {
- const {fileName, image, variant} = selection
+ prepare({fileName, image, variant}) {
const currentVariant = VARIANTS.find((v) => v.value === variant)
return {
diff --git a/packages/@sanity/cli/templates/shopify/schemaTypes/objects/module/images.tsx b/packages/@sanity/cli/templates/shopify/schemaTypes/objects/module/imageFeaturesType.tsx
similarity index 66%
rename from packages/@sanity/cli/templates/shopify/schemaTypes/objects/module/images.tsx
rename to packages/@sanity/cli/templates/shopify/schemaTypes/objects/module/imageFeaturesType.tsx
index b664da10ad8..c8470b8f6f9 100644
--- a/packages/@sanity/cli/templates/shopify/schemaTypes/objects/module/images.tsx
+++ b/packages/@sanity/cli/templates/shopify/schemaTypes/objects/module/imageFeaturesType.tsx
@@ -2,30 +2,26 @@ import {ImageIcon} from '@sanity/icons'
import pluralize from 'pluralize-esm'
import {defineField} from 'sanity'
-export default defineField({
- name: 'module.images',
+export const imageFeaturesType = defineField({
+ name: 'images',
title: 'Images',
type: 'object',
icon: ImageIcon,
fields: [
- // Modules (Images)
defineField({
- name: 'modules',
+ name: 'imageFeatures',
title: 'Images',
type: 'array',
- of: [{type: 'module.image'}],
+ of: [{type: 'imageFeature'}],
validation: (Rule) => Rule.required().max(2),
}),
- // Full width
defineField({
name: 'fullWidth',
- title: 'Full width',
type: 'boolean',
description: 'Display single image at full width (on larger breakpoints)',
initialValue: false,
hidden: ({parent}) => parent?.modules?.length > 1,
}),
- // Vertical alignment
defineField({
name: 'verticalAlign',
title: 'Vertical alignment',
@@ -34,20 +30,7 @@ export default defineField({
options: {
direction: 'horizontal',
layout: 'radio',
- list: [
- {
- title: 'Top',
- value: 'top',
- },
- {
- title: 'Center',
- value: 'center',
- },
- {
- title: 'Bottom',
- value: 'bottom',
- },
- ],
+ list: ['top', 'center', 'bottom'],
},
hidden: ({parent}) => !parent?.modules || parent?.modules?.length < 2,
validation: (Rule) => Rule.required(),
@@ -55,10 +38,9 @@ export default defineField({
],
preview: {
select: {
- images: 'modules',
+ images: 'imageFeatures',
},
- prepare(selection) {
- const {images} = selection
+ prepare({images}) {
return {
subtitle: 'Images',
title: images?.length > 0 ? pluralize('image', images.length, true) : 'No images',
diff --git a/packages/@sanity/cli/templates/shopify/schemaTypes/objects/module/instagram.ts b/packages/@sanity/cli/templates/shopify/schemaTypes/objects/module/instagramType.ts
similarity index 91%
rename from packages/@sanity/cli/templates/shopify/schemaTypes/objects/module/instagram.ts
rename to packages/@sanity/cli/templates/shopify/schemaTypes/objects/module/instagramType.ts
index e069cc1622d..8a27fe7b3a5 100644
--- a/packages/@sanity/cli/templates/shopify/schemaTypes/objects/module/instagram.ts
+++ b/packages/@sanity/cli/templates/shopify/schemaTypes/objects/module/instagramType.ts
@@ -1,8 +1,8 @@
import {UserIcon} from '@sanity/icons'
import {defineField} from 'sanity'
-export default defineField({
- name: 'module.instagram',
+export const instagramType = defineField({
+ name: 'instagram',
title: 'Instagram',
type: 'object',
icon: UserIcon,
diff --git a/packages/@sanity/cli/templates/shopify/schemaTypes/objects/module/products.tsx b/packages/@sanity/cli/templates/shopify/schemaTypes/objects/module/productFeaturesType.tsx
similarity index 76%
rename from packages/@sanity/cli/templates/shopify/schemaTypes/objects/module/products.tsx
rename to packages/@sanity/cli/templates/shopify/schemaTypes/objects/module/productFeaturesType.tsx
index 26d09ac2603..84449e40b6d 100644
--- a/packages/@sanity/cli/templates/shopify/schemaTypes/objects/module/products.tsx
+++ b/packages/@sanity/cli/templates/shopify/schemaTypes/objects/module/productFeaturesType.tsx
@@ -2,24 +2,20 @@ import {TagIcon} from '@sanity/icons'
import pluralize from 'pluralize-esm'
import {defineField} from 'sanity'
-export default defineField({
- name: 'module.products',
+export const productFeaturesType = defineField({
+ name: 'products',
title: 'Products',
type: 'object',
icon: TagIcon,
fields: [
- // Modules (products)
defineField({
- name: 'modules',
- title: 'Products',
+ name: 'products',
type: 'array',
- of: [{type: 'module.product'}],
+ of: [{type: 'productReference'}],
validation: (Rule) => Rule.required().max(2),
}),
- // Layout
defineField({
name: 'layout',
- title: 'Layout',
type: 'string',
initialValue: 'card',
options: {
@@ -41,10 +37,9 @@ export default defineField({
],
preview: {
select: {
- products: 'modules',
+ products: 'products',
},
- prepare(selection) {
- const {products} = selection
+ prepare({products}) {
return {
subtitle: 'Products',
title: products.length > 0 ? pluralize('product', products.length, true) : 'No products',
diff --git a/packages/@sanity/cli/templates/shopify/schemaTypes/objects/module/product.tsx b/packages/@sanity/cli/templates/shopify/schemaTypes/objects/module/productReferenceType.tsx
similarity index 81%
rename from packages/@sanity/cli/templates/shopify/schemaTypes/objects/module/product.tsx
rename to packages/@sanity/cli/templates/shopify/schemaTypes/objects/module/productReferenceType.tsx
index 7675bda5a0b..38347afff97 100644
--- a/packages/@sanity/cli/templates/shopify/schemaTypes/objects/module/product.tsx
+++ b/packages/@sanity/cli/templates/shopify/schemaTypes/objects/module/productReferenceType.tsx
@@ -1,21 +1,20 @@
import {TagIcon} from '@sanity/icons'
-import React from 'react'
+
import {defineField} from 'sanity'
import ShopifyDocumentStatus from '../../../components/media/ShopifyDocumentStatus'
-export default defineField({
- name: 'module.product',
+export const productReferenceType = defineField({
+ name: 'productReference',
title: 'Product',
type: 'object',
icon: TagIcon,
fields: [
- {
+ defineField({
name: 'productWithVariant',
- title: 'Product + Variant',
type: 'productWithVariant',
validation: (Rule) => Rule.required(),
- },
+ }),
],
preview: {
select: {
@@ -24,8 +23,7 @@ export default defineField({
status: 'productWithVariant.product.store.status',
title: 'productWithVariant.product.store.title',
},
- prepare(selection) {
- const {isDeleted, previewImageUrl, status, title} = selection
+ prepare({isDeleted, previewImageUrl, status, title}) {
return {
media: (
- Rule.max(150).warning('Longer descriptions may be truncated by search engines'),
-})
diff --git a/packages/@sanity/cli/templates/shopify/schemaTypes/objects/seo/home.tsx b/packages/@sanity/cli/templates/shopify/schemaTypes/objects/seo/home.tsx
deleted file mode 100644
index 4309b4f3ffc..00000000000
--- a/packages/@sanity/cli/templates/shopify/schemaTypes/objects/seo/home.tsx
+++ /dev/null
@@ -1,31 +0,0 @@
-import {defineField} from 'sanity'
-
-export default defineField({
- name: 'seo.home',
- title: 'SEO',
- type: 'object',
- options: {
- collapsed: false,
- collapsible: true,
- },
- fields: [
- defineField({
- name: 'title',
- title: 'Title',
- type: 'string',
- validation: (Rule) =>
- Rule.max(50).warning('Longer titles may be truncated by search engines'),
- }),
- defineField({
- name: 'description',
- title: 'Description',
- type: 'seo.description',
- }),
- defineField({
- name: 'image',
- title: 'Image',
- type: 'image',
- }),
- ],
- validation: (Rule) => Rule.required(),
-})
diff --git a/packages/@sanity/cli/templates/shopify/schemaTypes/objects/seo/page.tsx b/packages/@sanity/cli/templates/shopify/schemaTypes/objects/seo/page.tsx
deleted file mode 100644
index 2ecbcb4e444..00000000000
--- a/packages/@sanity/cli/templates/shopify/schemaTypes/objects/seo/page.tsx
+++ /dev/null
@@ -1,37 +0,0 @@
-import React from 'react'
-import {defineField} from 'sanity'
-
-export default defineField({
- name: 'seo.page',
- title: 'SEO',
- type: 'object',
- options: {
- collapsed: false,
- collapsible: true,
- },
- fields: [
- defineField({
- name: 'title',
- title: 'Title',
- type: 'placeholderString',
- description: (
- <>
- If empty, displays the document title (title
)
- >
- ),
- options: {field: 'title'},
- validation: (Rule) =>
- Rule.max(50).warning('Longer titles may be truncated by search engines'),
- }),
- defineField({
- name: 'description',
- title: 'Description',
- type: 'seo.description',
- }),
- defineField({
- name: 'image',
- title: 'Image',
- type: 'image',
- }),
- ],
-})
diff --git a/packages/@sanity/cli/templates/shopify/schemaTypes/objects/seo/shopify.tsx b/packages/@sanity/cli/templates/shopify/schemaTypes/objects/seo/shopify.tsx
deleted file mode 100644
index 1a50f3eebb3..00000000000
--- a/packages/@sanity/cli/templates/shopify/schemaTypes/objects/seo/shopify.tsx
+++ /dev/null
@@ -1,40 +0,0 @@
-import React from 'react'
-import {defineField} from 'sanity'
-
-export default defineField({
- name: 'seo.shopify',
- title: 'SEO',
- type: 'object',
- description: <>>,
- options: {
- collapsed: false,
- collapsible: true,
- },
- fields: [
- {
- name: 'title',
- title: 'Title',
- type: 'placeholderString',
- description: (
- <>
- If empty, displays the default Shopify document title (store.title
)
- >
- ),
- options: {
- field: 'store.title',
- },
- validation: (Rule) =>
- Rule.max(50).warning('Longer titles may be truncated by search engines'),
- },
- {
- name: 'description',
- title: 'Description',
- type: 'seo.description',
- },
- {
- name: 'image',
- title: 'Image',
- type: 'image',
- },
- ],
-})
diff --git a/packages/@sanity/cli/templates/shopify/schemaTypes/objects/seo/seo.ts b/packages/@sanity/cli/templates/shopify/schemaTypes/objects/seoType.ts
similarity index 68%
rename from packages/@sanity/cli/templates/shopify/schemaTypes/objects/seo/seo.ts
rename to packages/@sanity/cli/templates/shopify/schemaTypes/objects/seoType.ts
index b4c34de792e..ebb0a4bb8bb 100644
--- a/packages/@sanity/cli/templates/shopify/schemaTypes/objects/seo/seo.ts
+++ b/packages/@sanity/cli/templates/shopify/schemaTypes/objects/seoType.ts
@@ -1,11 +1,10 @@
import {defineField} from 'sanity'
-export default defineField({
+export const seoType = defineField({
name: 'seo',
title: 'SEO',
type: 'object',
group: 'seo',
- description: 'Defaults for every page',
options: {
collapsed: false,
collapsible: true,
@@ -13,18 +12,20 @@ export default defineField({
fields: [
defineField({
name: 'title',
- title: 'Site title',
type: 'string',
- validation: (Rule) => Rule.required(),
+ validation: (Rule) =>
+ Rule.max(50).warning('Longer titles may be truncated by search engines'),
}),
defineField({
name: 'description',
- title: 'Description',
type: 'text',
rows: 2,
validation: (Rule) =>
Rule.max(150).warning('Longer descriptions may be truncated by search engines'),
}),
+ defineField({
+ name: 'image',
+ type: 'image',
+ }),
],
- validation: (Rule) => Rule.required(),
})
diff --git a/packages/@sanity/cli/templates/shopify/schemaTypes/objects/shopify/shopifyCollectionRule.tsx b/packages/@sanity/cli/templates/shopify/schemaTypes/objects/shopify/collectionRuleType.tsx
similarity index 73%
rename from packages/@sanity/cli/templates/shopify/schemaTypes/objects/shopify/shopifyCollectionRule.tsx
rename to packages/@sanity/cli/templates/shopify/schemaTypes/objects/shopify/collectionRuleType.tsx
index 493d14f546e..4feedf404d3 100644
--- a/packages/@sanity/cli/templates/shopify/schemaTypes/objects/shopify/shopifyCollectionRule.tsx
+++ b/packages/@sanity/cli/templates/shopify/schemaTypes/objects/shopify/collectionRuleType.tsx
@@ -1,28 +1,22 @@
import {FilterIcon} from '@sanity/icons'
import {defineField} from 'sanity'
-export default defineField({
+export const collectionRuleType = defineField({
title: 'Collection rule',
name: 'collectionRule',
type: 'object',
icon: FilterIcon,
readOnly: true,
fields: [
- // Column
defineField({
- title: 'Column',
name: 'column',
type: 'string',
}),
- // Values
defineField({
- title: 'Relation',
name: 'relation',
type: 'string',
}),
- // Condition
defineField({
- title: 'Condition',
name: 'condition',
type: 'string',
}),
@@ -33,9 +27,7 @@ export default defineField({
name: 'column',
relation: 'relation',
},
- prepare(selection) {
- const {condition, name, relation} = selection
-
+ prepare({condition, name, relation}) {
return {
subtitle: `${relation} ${condition}`,
title: name,
diff --git a/packages/@sanity/cli/templates/shopify/schemaTypes/objects/shopify/inventory.ts b/packages/@sanity/cli/templates/shopify/schemaTypes/objects/shopify/inventoryType.ts
similarity index 65%
rename from packages/@sanity/cli/templates/shopify/schemaTypes/objects/shopify/inventory.ts
rename to packages/@sanity/cli/templates/shopify/schemaTypes/objects/shopify/inventoryType.ts
index 10b260b33b4..83377f2e0ff 100644
--- a/packages/@sanity/cli/templates/shopify/schemaTypes/objects/shopify/inventory.ts
+++ b/packages/@sanity/cli/templates/shopify/schemaTypes/objects/shopify/inventoryType.ts
@@ -1,6 +1,6 @@
import {defineField} from 'sanity'
-export default defineField({
+export const inventoryType = defineField({
name: 'inventory',
title: 'Inventory',
type: 'object',
@@ -8,23 +8,18 @@ export default defineField({
columns: 3,
},
fields: [
- // Available
- {
+ defineField({
name: 'isAvailable',
title: 'Available',
type: 'boolean',
- },
- // Management
- {
+ }),
+ defineField({
name: 'management',
- title: 'Management',
type: 'string',
- },
- // Policy
- {
+ }),
+ defineField({
name: 'policy',
- title: 'Policy',
type: 'string',
- },
+ }),
],
})
diff --git a/packages/@sanity/cli/templates/shopify/schemaTypes/objects/shopify/option.tsx b/packages/@sanity/cli/templates/shopify/schemaTypes/objects/shopify/optionType.tsx
similarity index 69%
rename from packages/@sanity/cli/templates/shopify/schemaTypes/objects/shopify/option.tsx
rename to packages/@sanity/cli/templates/shopify/schemaTypes/objects/shopify/optionType.tsx
index a5033011229..07be80525fe 100644
--- a/packages/@sanity/cli/templates/shopify/schemaTypes/objects/shopify/option.tsx
+++ b/packages/@sanity/cli/templates/shopify/schemaTypes/objects/shopify/optionType.tsx
@@ -1,34 +1,28 @@
import {SunIcon} from '@sanity/icons'
import {defineField} from 'sanity'
-export default defineField({
+export const optionType = defineField({
title: 'Product option',
name: 'option',
type: 'object',
icon: SunIcon,
readOnly: true,
fields: [
- // Name
- {
- title: 'Name',
+ defineField({
name: 'name',
type: 'string',
- },
- // Values
- {
- title: 'Values',
+ }),
+ defineField({
name: 'values',
type: 'array',
of: [{type: 'string'}],
- },
+ }),
],
preview: {
select: {
name: 'name',
},
- prepare(selection) {
- const {name} = selection
-
+ prepare({name}) {
return {
title: name,
}
diff --git a/packages/@sanity/cli/templates/shopify/schemaTypes/objects/shopify/placeholderString.ts b/packages/@sanity/cli/templates/shopify/schemaTypes/objects/shopify/placeholderStringType.ts
similarity index 70%
rename from packages/@sanity/cli/templates/shopify/schemaTypes/objects/shopify/placeholderString.ts
rename to packages/@sanity/cli/templates/shopify/schemaTypes/objects/shopify/placeholderStringType.ts
index 74e23012f49..161b83236fd 100644
--- a/packages/@sanity/cli/templates/shopify/schemaTypes/objects/shopify/placeholderString.ts
+++ b/packages/@sanity/cli/templates/shopify/schemaTypes/objects/shopify/placeholderStringType.ts
@@ -1,6 +1,7 @@
+import { defineType } from 'sanity'
import PlaceholderStringInput from '../../../components/inputs/PlaceholderString'
-export default {
+export const placeholderStringType = defineType({
name: 'placeholderString',
title: 'Title',
type: 'string',
@@ -8,3 +9,4 @@ export default {
input: PlaceholderStringInput,
},
}
+)
\ No newline at end of file
diff --git a/packages/@sanity/cli/templates/shopify/schemaTypes/objects/shopify/priceRange.ts b/packages/@sanity/cli/templates/shopify/schemaTypes/objects/shopify/priceRangeType.ts
similarity index 67%
rename from packages/@sanity/cli/templates/shopify/schemaTypes/objects/shopify/priceRange.ts
rename to packages/@sanity/cli/templates/shopify/schemaTypes/objects/shopify/priceRangeType.ts
index dc1883dce1e..958de5b2612 100644
--- a/packages/@sanity/cli/templates/shopify/schemaTypes/objects/shopify/priceRange.ts
+++ b/packages/@sanity/cli/templates/shopify/schemaTypes/objects/shopify/priceRangeType.ts
@@ -1,6 +1,6 @@
import {defineField} from 'sanity'
-export default defineField({
+export const priceRangeType = defineField({
name: 'priceRange',
title: 'Price range',
type: 'object',
@@ -8,15 +8,13 @@ export default defineField({
columns: 2,
},
fields: [
- {
+ defineField({
name: 'minVariantPrice',
- title: 'Min variant price',
type: 'number',
- },
- {
+ }),
+ defineField({
name: 'maxVariantPrice',
- title: 'Max variant price',
type: 'number',
- },
+ }),
],
})
diff --git a/packages/@sanity/cli/templates/shopify/schemaTypes/objects/shopify/productWithVariant.tsx b/packages/@sanity/cli/templates/shopify/schemaTypes/objects/shopify/productWithVariantType.tsx
similarity index 98%
rename from packages/@sanity/cli/templates/shopify/schemaTypes/objects/shopify/productWithVariant.tsx
rename to packages/@sanity/cli/templates/shopify/schemaTypes/objects/shopify/productWithVariantType.tsx
index 04aa0de1dd7..bd1a25792f5 100644
--- a/packages/@sanity/cli/templates/shopify/schemaTypes/objects/shopify/productWithVariant.tsx
+++ b/packages/@sanity/cli/templates/shopify/schemaTypes/objects/shopify/productWithVariantType.tsx
@@ -1,13 +1,13 @@
import {TagIcon} from '@sanity/icons'
import pluralize from 'pluralize-esm'
-import React from 'react'
+
import {defineField} from 'sanity'
import ShopifyDocumentStatus from '../../../components/media/ShopifyDocumentStatus'
import {SANITY_API_VERSION} from '../../../constants'
import {getPriceRange} from '../../../utils/getPriceRange'
-export default defineField({
+export const productWithVariantType = defineField({
name: 'productWithVariant',
title: 'Product with variant',
type: 'object',
diff --git a/packages/@sanity/cli/templates/shopify/schemaTypes/objects/shopify/proxyString.ts b/packages/@sanity/cli/templates/shopify/schemaTypes/objects/shopify/proxyStringType.ts
similarity index 82%
rename from packages/@sanity/cli/templates/shopify/schemaTypes/objects/shopify/proxyString.ts
rename to packages/@sanity/cli/templates/shopify/schemaTypes/objects/shopify/proxyStringType.ts
index 999c7fe7486..205d76aa330 100644
--- a/packages/@sanity/cli/templates/shopify/schemaTypes/objects/shopify/proxyString.ts
+++ b/packages/@sanity/cli/templates/shopify/schemaTypes/objects/shopify/proxyStringType.ts
@@ -2,7 +2,7 @@ import {defineField} from 'sanity'
import ProxyStringInput from '../../../components/inputs/ProxyString'
-export default defineField({
+export const proxyStringType = defineField({
name: 'proxyString',
title: 'Title',
type: 'string',
diff --git a/packages/@sanity/cli/templates/shopify/schemaTypes/objects/shopify/shopifyCollection.ts b/packages/@sanity/cli/templates/shopify/schemaTypes/objects/shopify/shopifyCollectionType.ts
similarity index 78%
rename from packages/@sanity/cli/templates/shopify/schemaTypes/objects/shopify/shopifyCollection.ts
rename to packages/@sanity/cli/templates/shopify/schemaTypes/objects/shopify/shopifyCollectionType.ts
index 153ca775c6f..aa2da197520 100644
--- a/packages/@sanity/cli/templates/shopify/schemaTypes/objects/shopify/shopifyCollection.ts
+++ b/packages/@sanity/cli/templates/shopify/schemaTypes/objects/shopify/shopifyCollectionType.ts
@@ -1,6 +1,6 @@
import {defineField} from 'sanity'
-export default defineField({
+export const shopifyCollectionType = defineField({
name: 'shopifyCollection',
title: 'Shopify',
type: 'object',
@@ -16,90 +16,69 @@ export default defineField({
},
],
fields: [
- // Created at
defineField({
fieldset: 'status',
name: 'createdAt',
- title: 'Created at',
type: 'string',
}),
- // Updated at
defineField({
fieldset: 'status',
name: 'updatedAt',
- title: 'Updated at',
type: 'string',
}),
- // Deleted
defineField({
fieldset: 'status',
name: 'isDeleted',
title: 'Deleted from Shopify?',
type: 'boolean',
}),
- // Title
- {
+ defineField({
name: 'title',
- title: 'Title',
type: 'string',
- },
- // Collection ID
+ }),
defineField({
name: 'id',
title: 'ID',
type: 'number',
description: 'Shopify Collection ID',
}),
- // GID
defineField({
name: 'gid',
title: 'GID',
type: 'string',
description: 'Shopify Collection GID',
}),
- // Slug
defineField({
name: 'slug',
- title: 'Slug',
description: 'Shopify Collection handle',
type: 'slug',
}),
- // Description
defineField({
name: 'descriptionHtml',
title: 'HTML Description',
type: 'text',
rows: 5,
}),
- // Image URL
defineField({
name: 'imageUrl',
title: 'Image URL',
type: 'string',
}),
- // Rules
defineField({
name: 'rules',
- title: 'Rules',
type: 'array',
description: 'Include Shopify products that satisfy these conditions',
- of: [
- {
- type: 'collectionRule',
- },
+ of: [{type: 'collectionRule'},
],
}),
- // Disjunctive rules
defineField({
name: 'disjunctive',
title: 'Disjunctive rules?',
description: 'Require any condition if true, otherwise require all conditions',
type: 'boolean',
}),
- // Sort order
defineField({
name: 'sortOrder',
- title: 'Sort order',
type: 'string',
}),
],
diff --git a/packages/@sanity/cli/templates/shopify/schemaTypes/objects/shopify/shopifyProduct.ts b/packages/@sanity/cli/templates/shopify/schemaTypes/objects/shopify/shopifyProductType.ts
similarity index 78%
rename from packages/@sanity/cli/templates/shopify/schemaTypes/objects/shopify/shopifyProduct.ts
rename to packages/@sanity/cli/templates/shopify/schemaTypes/objects/shopify/shopifyProductType.ts
index cdade587272..c06d94da69b 100644
--- a/packages/@sanity/cli/templates/shopify/schemaTypes/objects/shopify/shopifyProduct.ts
+++ b/packages/@sanity/cli/templates/shopify/schemaTypes/objects/shopify/shopifyProductType.ts
@@ -1,6 +1,6 @@
-import {defineField} from 'sanity'
+import {defineArrayMember, defineField} from 'sanity'
-export default defineField({
+export const shopifyProductType = defineField({
name: 'shopifyProduct',
title: 'Shopify',
type: 'object',
@@ -31,131 +31,101 @@ export default defineField({
},
],
fields: [
- // Created at
defineField({
fieldset: 'status',
name: 'createdAt',
- title: 'Created at',
type: 'string',
}),
- // Updated at
defineField({
fieldset: 'status',
name: 'updatedAt',
- title: 'Updated at',
type: 'string',
}),
- // Product status
defineField({
fieldset: 'status',
name: 'status',
- title: 'Product status',
type: 'string',
options: {
layout: 'dropdown',
list: ['active', 'archived', 'draft'],
},
}),
- // Deleted
defineField({
fieldset: 'status',
name: 'isDeleted',
title: 'Deleted from Shopify?',
type: 'boolean',
}),
- // Title
defineField({
name: 'title',
- title: 'Title',
type: 'string',
description: 'Title displayed in both cart and checkout',
}),
- // Product ID
defineField({
name: 'id',
title: 'ID',
type: 'number',
description: 'Shopify Product ID',
}),
- // Product ID
defineField({
name: 'gid',
title: 'GID',
type: 'string',
description: 'Shopify Product GID',
}),
- // Slug
defineField({
name: 'slug',
- title: 'Slug',
type: 'slug',
description: 'Shopify Product handle',
}),
- // Description
defineField({
name: 'descriptionHtml',
title: 'HTML Description',
type: 'text',
rows: 5,
}),
- // Product Type
defineField({
fieldset: 'organization',
name: 'productType',
- title: 'Product type',
type: 'string',
}),
- // Vendor
defineField({
fieldset: 'organization',
name: 'vendor',
- title: 'Vendor',
type: 'string',
}),
- // Tags
defineField({
fieldset: 'organization',
name: 'tags',
- title: 'Tags',
type: 'string',
}),
- // Price range
defineField({
name: 'priceRange',
- title: 'Price range',
type: 'priceRange',
}),
- // Preview Image URL
defineField({
name: 'previewImageUrl',
title: 'Preview Image URL',
type: 'string',
description: 'Image displayed in both cart and checkout',
}),
- // Options
defineField({
name: 'options',
- title: 'Options',
type: 'array',
- of: [
- {
- type: 'option',
- },
+ of: [{type: 'option'},
],
}),
- // Variants
defineField({
fieldset: 'variants',
name: 'variants',
- title: 'Variants',
type: 'array',
of: [
- {
+ defineArrayMember({
title: 'Variant',
type: 'reference',
weak: true,
to: [{type: 'productVariant'}],
- },
+ }),
],
}),
],
diff --git a/packages/@sanity/cli/templates/shopify/schemaTypes/objects/shopify/shopifyProductVariant.ts b/packages/@sanity/cli/templates/shopify/schemaTypes/objects/shopify/shopifyProductVariantType.ts
similarity index 81%
rename from packages/@sanity/cli/templates/shopify/schemaTypes/objects/shopify/shopifyProductVariant.ts
rename to packages/@sanity/cli/templates/shopify/schemaTypes/objects/shopify/shopifyProductVariantType.ts
index 174d98d9def..0c268208e2d 100644
--- a/packages/@sanity/cli/templates/shopify/schemaTypes/objects/shopify/shopifyProductVariant.ts
+++ b/packages/@sanity/cli/templates/shopify/schemaTypes/objects/shopify/shopifyProductVariantType.ts
@@ -1,6 +1,6 @@
import {defineField} from 'sanity'
-export default defineField({
+export const shopifyProductVariantType = defineField({
name: 'shopifyProductVariant',
title: 'Shopify',
type: 'object',
@@ -22,25 +22,19 @@ export default defineField({
},
],
fields: [
- // Created at
defineField({
fieldset: 'status',
name: 'createdAt',
- title: 'Created at',
type: 'string',
}),
- // Updated at
defineField({
fieldset: 'status',
name: 'updatedAt',
- title: 'Updated at',
type: 'string',
}),
- // Product status
defineField({
fieldset: 'status',
name: 'status',
- title: 'Product status',
type: 'string',
options: {
layout: 'dropdown',
@@ -48,91 +42,71 @@ export default defineField({
},
validation: (Rule) => Rule.required(),
}),
- // Deleted
defineField({
fieldset: 'status',
name: 'isDeleted',
title: 'Deleted from Shopify?',
type: 'boolean',
}),
- // Title
defineField({
name: 'title',
- title: 'Title',
type: 'string',
}),
- // SKU
defineField({
name: 'sku',
title: 'SKU',
type: 'string',
}),
- // ID
defineField({
name: 'id',
title: 'ID',
type: 'number',
description: 'Shopify Product Variant ID',
}),
- // GID
defineField({
name: 'gid',
title: 'GID',
type: 'string',
description: 'Shopify Product Variant GID',
}),
- // Product ID
defineField({
name: 'productId',
title: 'Product ID',
type: 'number',
}),
- // Product GID
defineField({
name: 'productGid',
title: 'Product GID',
type: 'string',
}),
- // Price
defineField({
name: 'price',
- title: 'Price',
type: 'number',
}),
- // Compare at price
defineField({
name: 'compareAtPrice',
- title: 'Compare at price',
type: 'number',
}),
- // Inventory
defineField({
name: 'inventory',
- title: 'Inventory',
type: 'inventory',
options: {
columns: 3,
},
}),
- // Option 1
defineField({
fieldset: 'options',
name: 'option1',
- title: 'Option 1',
type: 'string',
}),
- // Option 2
defineField({
fieldset: 'options',
name: 'option2',
- title: 'Option 2',
type: 'string',
}),
- // Option 3
defineField({
fieldset: 'options',
name: 'option3',
- title: 'Option 3',
type: 'string',
}),
// Preview Image URL
diff --git a/packages/@sanity/cli/templates/shopify/schemaTypes/portableText/portableTextSimpleType.tsx b/packages/@sanity/cli/templates/shopify/schemaTypes/portableText/portableTextSimpleType.tsx
new file mode 100644
index 00000000000..0d0b6cafea3
--- /dev/null
+++ b/packages/@sanity/cli/templates/shopify/schemaTypes/portableText/portableTextSimpleType.tsx
@@ -0,0 +1,45 @@
+import {defineArrayMember, defineField} from 'sanity'
+
+export const portableTextSimpleType = defineField({
+ name: 'portableTextSimple',
+ type: 'array',
+ of: [
+ defineArrayMember({
+ lists: [
+ {title: 'Bullet', value: 'bullet'},
+ {title: 'Numbered', value: 'number'},
+ ],
+ marks: {
+ decorators: [
+ {
+ title: 'Italic',
+ value: 'em',
+ },
+ {
+ title: 'Strong',
+ value: 'strong',
+ },
+ ],
+ annotations: [
+ {
+ name: 'linkProduct',
+ type: 'linkProduct',
+ },
+ {
+ name: 'linkEmail',
+ type: 'linkEmail',
+ },
+ {
+ name: 'linkInternal',
+ type: 'linkInternal',
+ },
+ {
+ name: 'linkExternal',
+ type: 'linkExternal',
+ },
+ ],
+ },
+ type: 'block',
+ }),
+ ],
+})
diff --git a/packages/@sanity/cli/templates/shopify/schemaTypes/portableText/portableTextType.tsx b/packages/@sanity/cli/templates/shopify/schemaTypes/portableText/portableTextType.tsx
new file mode 100644
index 00000000000..121ec9f8d3c
--- /dev/null
+++ b/packages/@sanity/cli/templates/shopify/schemaTypes/portableText/portableTextType.tsx
@@ -0,0 +1,52 @@
+import {defineArrayMember, defineField} from 'sanity'
+
+export const portableTextType = defineField({
+ name: 'portableText',
+ type: 'array',
+ of: [
+ defineArrayMember({
+ lists: [
+ {title: 'Bullet', value: 'bullet'},
+ {title: 'Numbered', value: 'number'},
+ ],
+ marks: {
+ decorators: [
+ {
+ title: 'Italic',
+ value: 'em',
+ },
+ {
+ title: 'Strong',
+ value: 'strong',
+ },
+ ],
+ annotations: [
+ {
+ name: 'linkProduct',
+ type: 'linkProduct',
+ },
+ {
+ name: 'linkEmail',
+ type: 'linkEmail',
+ },
+ {
+ name: 'linkInternal',
+ type: 'linkInternal',
+ },
+ {
+ name: 'linkExternal',
+ type: 'linkExternal',
+ },
+ ],
+ },
+ type: 'block',
+ }),
+ defineArrayMember({ type: 'accordion' }),
+ defineArrayMember({ type: 'callout' }),
+ defineArrayMember({ type: 'grid' }),
+ defineArrayMember({ type: 'images' }),
+ defineArrayMember({ type: 'imageWithProductHotspots', title: 'Image with Hotspots' }),
+ defineArrayMember({ type: 'instagram' }),
+ defineArrayMember({ type: 'products' }),
+ ],
+})
diff --git a/packages/@sanity/cli/templates/shopify/schemaTypes/singletons/home.ts b/packages/@sanity/cli/templates/shopify/schemaTypes/singletons/home.ts
deleted file mode 100644
index eb158a786d6..00000000000
--- a/packages/@sanity/cli/templates/shopify/schemaTypes/singletons/home.ts
+++ /dev/null
@@ -1,62 +0,0 @@
-import {HomeIcon} from '@sanity/icons'
-import {defineField} from 'sanity'
-
-const TITLE = 'Home'
-
-export default defineField({
- name: 'home',
- title: TITLE,
- type: 'document',
- icon: HomeIcon,
- groups: [
- {
- default: true,
- name: 'editorial',
- title: 'Editorial',
- },
- {
- name: 'seo',
- title: 'SEO',
- },
- ],
- fields: [
- // Hero
- defineField({
- name: 'hero',
- title: 'Hero',
- type: 'hero.home',
- group: 'editorial',
- }),
- // Modules
- defineField({
- name: 'modules',
- title: 'Modules',
- type: 'array',
- of: [
- {type: 'module.callout'},
- {type: 'module.callToAction'},
- {type: 'module.collection'},
- {type: 'module.image'},
- {type: 'module.instagram'},
- {type: 'module.product'},
- ],
- group: 'editorial',
- }),
- // SEO
- defineField({
- name: 'seo',
- title: 'SEO',
- type: 'seo.home',
- group: 'seo',
- }),
- ],
- preview: {
- prepare() {
- return {
- // media: icon,
- subtitle: 'Index',
- title: TITLE,
- }
- },
- },
-})
diff --git a/packages/@sanity/cli/templates/shopify/schemaTypes/singletons/homeType.ts b/packages/@sanity/cli/templates/shopify/schemaTypes/singletons/homeType.ts
new file mode 100644
index 00000000000..1834a7a573e
--- /dev/null
+++ b/packages/@sanity/cli/templates/shopify/schemaTypes/singletons/homeType.ts
@@ -0,0 +1,49 @@
+import {HomeIcon} from '@sanity/icons'
+import {defineArrayMember, defineField} from 'sanity'
+import { GROUPS } from '../../constants'
+
+const TITLE = 'Home'
+
+export const homeType = defineField({
+ name: 'home',
+ title: TITLE,
+ type: 'document',
+ icon: HomeIcon,
+ groups: GROUPS,
+ fields: [
+ defineField({
+ name: 'hero',
+ type: 'hero',
+ group: 'editorial',
+ }),
+ defineField({
+ name: 'modules',
+ type: 'array',
+ of: [
+ defineArrayMember({ type: 'accordion' }),
+ defineArrayMember({ type: 'callout' }),
+ defineArrayMember({ type: 'grid' }),
+ defineArrayMember({ type: 'images' }),
+ defineArrayMember({ type: 'imageWithProductHotspots', title: 'Image with Hotspots' }),
+ defineArrayMember({ type: 'instagram' }),
+ defineArrayMember({ type: 'products' }),
+ ],
+ group: 'editorial',
+ }),
+ defineField({
+ name: 'seo',
+ title: 'SEO',
+ type: 'seo',
+ group: 'seo',
+ }),
+ ],
+ preview: {
+ prepare() {
+ return {
+ media: HomeIcon,
+ subtitle: 'Index',
+ title: TITLE,
+ }
+ },
+ },
+})
diff --git a/packages/@sanity/cli/templates/shopify/schemaTypes/singletons/settings.ts b/packages/@sanity/cli/templates/shopify/schemaTypes/singletons/settingsType.ts
similarity index 87%
rename from packages/@sanity/cli/templates/shopify/schemaTypes/singletons/settings.ts
rename to packages/@sanity/cli/templates/shopify/schemaTypes/singletons/settingsType.ts
index 3fce1b99eb5..90ce7b8012e 100644
--- a/packages/@sanity/cli/templates/shopify/schemaTypes/singletons/settings.ts
+++ b/packages/@sanity/cli/templates/shopify/schemaTypes/singletons/settingsType.ts
@@ -1,4 +1,4 @@
-import {CogIcon} from '@sanity/icons'
+import {CogIcon, ControlsIcon, ErrorOutlineIcon, MenuIcon, SearchIcon} from '@sanity/icons'
import {defineType, defineField} from 'sanity'
const TITLE = 'Settings'
@@ -6,7 +6,7 @@ interface ProductOptions {
title: string
}
-export default defineType({
+export const settingsType = defineType({
name: 'settings',
title: TITLE,
type: 'document',
@@ -16,39 +16,37 @@ export default defineType({
default: true,
name: 'navigation',
title: 'Navigation',
+ icon: MenuIcon,
},
{
name: 'productOptions',
title: 'Product options',
+ icon: ControlsIcon,
},
{
name: 'notFoundPage',
title: '404 page',
+ icon: ErrorOutlineIcon,
},
{
name: 'seo',
title: 'SEO',
+ icon: SearchIcon,
},
],
fields: [
- // Menu
defineField({
name: 'menu',
- title: 'Menu',
- type: 'menuSettings',
+ type: 'menu',
group: 'navigation',
}),
- // Footer
defineField({
name: 'footer',
- title: 'Footer',
type: 'footerSettings',
group: 'navigation',
}),
- // Custom product options
defineField({
name: 'customProductOptions',
- title: 'Custom product options',
type: 'array',
group: 'productOptions',
of: [
diff --git a/packages/@sanity/cli/templates/shopify/utils/shopifyUrls.ts b/packages/@sanity/cli/templates/shopify/utils/shopifyUrls.ts
index 74f22be741b..58e66c4bcf3 100644
--- a/packages/@sanity/cli/templates/shopify/utils/shopifyUrls.ts
+++ b/packages/@sanity/cli/templates/shopify/utils/shopifyUrls.ts
@@ -4,19 +4,19 @@ export const collectionUrl = (collectionId: number) => {
if (!SHOPIFY_STORE_ID) {
return null
}
- return `https://${SHOPIFY_STORE_ID}/admin/collections/${collectionId}`
+ return `https://admin.shopify.com/store/${SHOPIFY_STORE_ID}/collections/${collectionId}`
}
export const productUrl = (productId: number) => {
if (!SHOPIFY_STORE_ID) {
return null
}
- return `https://${SHOPIFY_STORE_ID}/admin/products/${productId}`
+ return `https://admin.shopify.com/store/${SHOPIFY_STORE_ID}/products/${productId}`
}
export const productVariantUrl = (productId: number, productVariantId: number) => {
if (!SHOPIFY_STORE_ID) {
return null
}
- return `https://${SHOPIFY_STORE_ID}/admin/products/${productId}/variants/${productVariantId}`
+ return `https://admin.shopify.com/store/${SHOPIFY_STORE_ID}/products/${productId}/variants/${productVariantId}`
}
diff --git a/packages/@sanity/cli/templates/shopify/utils/validateSlug.ts b/packages/@sanity/cli/templates/shopify/utils/validateSlug.ts
index e6a7d83e171..cf9fe4fd731 100644
--- a/packages/@sanity/cli/templates/shopify/utils/validateSlug.ts
+++ b/packages/@sanity/cli/templates/shopify/utils/validateSlug.ts
@@ -1,10 +1,9 @@
-import {Rule, Slug} from 'sanity'
-import slug from 'slug'
+import {SlugRule} from 'sanity'
const MAX_LENGTH = 96
-export const validateSlug = (Rule: Rule) => {
- return Rule.required().custom(async (value: Slug) => {
+export const validateSlug = (Rule: SlugRule) => {
+ return Rule.required().custom((value) => {
const currentSlug = value && value.current
if (!currentSlug) {
return true
@@ -14,9 +13,6 @@ export const validateSlug = (Rule: Rule) => {
return `Must be less than ${MAX_LENGTH} characters`
}
- if (currentSlug !== slug(currentSlug, {lower: true})) {
- return 'Must be a valid slug'
- }
return true
})
}