@sanity/cli 3.36.4 → 3.36.5-canary.34
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/_chunks-cjs/cli.js +1779 -1317
- package/lib/_chunks-cjs/cli.js.map +1 -1
- package/lib/_chunks-cjs/journeyConfig.js +11 -11
- package/lib/_chunks-cjs/journeyConfig.js.map +1 -1
- package/lib/_chunks-cjs/loadEnv.js +105 -2719
- package/lib/_chunks-cjs/loadEnv.js.map +1 -1
- package/lib/cli.d.ts +10 -0
- package/lib/index.d.ts +448 -0
- package/lib/index.esm.js +449 -5
- package/lib/index.esm.js.map +1 -1
- package/lib/index.js +3 -3
- package/lib/index.js.map +1 -1
- package/lib/index.mjs +452 -0
- package/lib/index.mjs.map +1 -0
- package/lib/run.d.ts +1 -0
- package/lib/workers/getAndWriteJourneySchema.d.ts +1 -0
- package/lib/workers/getCliConfig.d.ts +1 -0
- package/lib/workers/typegenGenerate.d.ts +37 -0
- package/lib/workers/typegenGenerate.js +6 -2
- package/lib/workers/typegenGenerate.js.map +1 -1
- package/package.json +18 -21
- package/src/actions/init-project/templates/shopify.ts +7 -0
- package/src/util/journeyConfig.ts +5 -5
- package/templates/ecommerce/plugins/barcode-input/BarcodeInput.js +1 -1
- package/templates/get-started/plugins/sanity-plugin-tutorial/GetStartedTutorial.tsx +1 -1
- package/templates/shared/tsconfig.json +2 -4
- package/templates/shopify/README.md +3 -3
- package/templates/shopify/components/hotspots/ProductTooltip.tsx +1 -1
- package/templates/shopify/components/icons/Shopify.tsx +1 -1
- package/templates/shopify/components/inputs/CollectionHidden.tsx +1 -1
- package/templates/shopify/components/media/ColorTheme.tsx +1 -1
- package/templates/shopify/components/studio/Navbar.tsx +29 -0
- package/templates/shopify/constants.ts +31 -1
- package/templates/shopify/docs/features.md +6 -7
- package/templates/shopify/schemaTypes/documents/collection.tsx +11 -47
- package/templates/shopify/schemaTypes/documents/colorTheme.tsx +2 -17
- package/templates/shopify/schemaTypes/documents/page.ts +10 -37
- package/templates/shopify/schemaTypes/documents/product.tsx +4 -27
- package/templates/shopify/schemaTypes/documents/productVariant.tsx +4 -13
- package/templates/shopify/schemaTypes/index.ts +97 -126
- package/templates/shopify/schemaTypes/objects/collection/{group.ts → collectionGroupType.ts} +7 -10
- package/templates/shopify/schemaTypes/objects/collection/{links.ts → collectionLinksType.ts} +4 -4
- package/templates/shopify/schemaTypes/objects/customProductOption/{colorObject.tsx → customProductOptionColorObjectType.tsx} +3 -6
- package/templates/shopify/schemaTypes/objects/customProductOption/{color.tsx → customProductOptionColorType.tsx} +2 -10
- package/templates/shopify/schemaTypes/objects/customProductOption/{sizeObject.ts → customProductOptionSizeObjectType.ts} +3 -7
- package/templates/shopify/schemaTypes/objects/customProductOption/{size.ts → customProductOptionSizeType.ts} +3 -12
- package/templates/shopify/schemaTypes/objects/global/footerType.ts +22 -0
- package/templates/shopify/schemaTypes/objects/global/menuLinksType.ts +21 -0
- package/templates/shopify/schemaTypes/objects/global/{menu.ts → menuType.ts} +2 -4
- package/templates/shopify/schemaTypes/objects/global/{notFoundPage.ts → notFoundPageType.ts} +1 -6
- package/templates/shopify/schemaTypes/objects/hotspot/{imageWithProductHotspots.ts → imageWithProductHotspotsType.ts} +4 -6
- package/templates/shopify/schemaTypes/objects/hotspot/{productHotspots.tsx → productHotspotsType.tsx} +3 -5
- package/templates/shopify/schemaTypes/objects/hotspot/{spot.tsx → spotType.tsx} +1 -3
- package/templates/shopify/schemaTypes/{annotations/linkEmail.tsx → objects/link/linkEmailType.tsx} +5 -13
- package/templates/shopify/schemaTypes/{annotations/linkExternal.tsx → objects/link/linkExternalType.tsx} +6 -13
- package/templates/shopify/schemaTypes/{annotations/linkInternal.tsx → objects/link/linkInternalType.tsx} +5 -12
- package/templates/shopify/schemaTypes/{annotations/product.tsx → objects/link/linkProductType.tsx} +4 -16
- package/templates/shopify/schemaTypes/objects/module/{accordionGroup.ts → accordionGroupType.ts} +6 -9
- package/templates/shopify/schemaTypes/objects/module/{accordion.ts → accordionType.ts} +4 -11
- package/templates/shopify/schemaTypes/objects/module/{callToAction.tsx → callToActionType.tsx} +10 -23
- package/templates/shopify/schemaTypes/objects/module/{callout.ts → calloutType.ts} +4 -10
- package/templates/shopify/schemaTypes/objects/module/{collection.tsx → collectionReferenceType.tsx} +4 -9
- package/templates/shopify/schemaTypes/objects/module/gridItemType.ts +41 -0
- package/templates/shopify/schemaTypes/objects/module/{grid.ts → gridType.ts} +7 -15
- package/templates/shopify/schemaTypes/objects/{hero/home.tsx → module/heroType.tsx} +14 -17
- package/templates/shopify/schemaTypes/objects/module/{imageCallToAction.tsx → imageCallToActionType.tsx} +6 -10
- package/templates/shopify/schemaTypes/objects/module/{image.ts → imageFeatureType.ts} +6 -18
- package/templates/shopify/schemaTypes/objects/module/{images.tsx → imageFeaturesType.tsx} +7 -25
- package/templates/shopify/schemaTypes/objects/module/{instagram.ts → instagramType.ts} +2 -2
- package/templates/shopify/schemaTypes/objects/module/{products.tsx → productFeaturesType.tsx} +6 -11
- package/templates/shopify/schemaTypes/objects/module/{product.tsx → productReferenceType.tsx} +6 -8
- package/templates/shopify/schemaTypes/objects/{seo/seo.ts → seoType.ts} +7 -6
- package/templates/shopify/schemaTypes/objects/shopify/{shopifyCollectionRule.tsx → collectionRuleType.tsx} +2 -10
- package/templates/shopify/schemaTypes/objects/shopify/{inventory.ts → inventoryType.ts} +7 -12
- package/templates/shopify/schemaTypes/objects/shopify/{option.tsx → optionType.tsx} +6 -12
- package/templates/shopify/schemaTypes/objects/shopify/{placeholderString.ts → placeholderStringType.ts} +3 -1
- package/templates/shopify/schemaTypes/objects/shopify/{priceRange.ts → priceRangeType.ts} +5 -7
- package/templates/shopify/schemaTypes/objects/shopify/{productWithVariant.tsx → productWithVariantType.tsx} +2 -2
- package/templates/shopify/schemaTypes/objects/shopify/{proxyString.ts → proxyStringType.ts} +1 -1
- package/templates/shopify/schemaTypes/objects/shopify/{shopifyCollection.ts → shopifyCollectionType.ts} +4 -25
- package/templates/shopify/schemaTypes/objects/shopify/{shopifyProduct.ts → shopifyProductType.ts} +5 -35
- package/templates/shopify/schemaTypes/objects/shopify/{shopifyProductVariant.ts → shopifyProductVariantType.ts} +1 -27
- package/templates/shopify/schemaTypes/portableText/portableTextSimpleType.tsx +45 -0
- package/templates/shopify/schemaTypes/portableText/portableTextType.tsx +52 -0
- package/templates/shopify/schemaTypes/singletons/homeType.ts +49 -0
- package/templates/shopify/schemaTypes/singletons/{settings.ts → settingsType.ts} +7 -9
- package/templates/shopify/utils/shopifyUrls.ts +3 -3
- package/templates/shopify/utils/validateSlug.ts +3 -7
- package/lib/_chunks-cjs/index.js +0 -547
- package/lib/_chunks-cjs/index.js.map +0 -1
- package/lib/_chunks-cjs/node.js +0 -213
- package/lib/_chunks-cjs/node.js.map +0 -1
- package/lib/_chunks-cjs/stegaEncodeSourceMap.js +0 -357
- package/lib/_chunks-cjs/stegaEncodeSourceMap.js.map +0 -1
- package/lib/_chunks-es/index.js +0 -3336
- package/lib/_chunks-es/index.js.map +0 -1
- package/lib/_chunks-es/node.js +0 -216
- package/lib/_chunks-es/node.js.map +0 -1
- package/lib/_chunks-es/stegaEncodeSourceMap.js +0 -358
- package/lib/_chunks-es/stegaEncodeSourceMap.js.map +0 -1
- package/lib/index.cjs.mjs +0 -7
- package/templates/shopify/schemaTypes/blocks/body.tsx +0 -70
- package/templates/shopify/schemaTypes/objects/global/footer.ts +0 -57
- package/templates/shopify/schemaTypes/objects/global/linkExternal.ts +0 -52
- package/templates/shopify/schemaTypes/objects/global/linkInternal.ts +0 -65
- package/templates/shopify/schemaTypes/objects/global/links.ts +0 -16
- package/templates/shopify/schemaTypes/objects/hero/collection.tsx +0 -42
- package/templates/shopify/schemaTypes/objects/hero/page.tsx +0 -35
- package/templates/shopify/schemaTypes/objects/module/accordionBody.ts +0 -45
- package/templates/shopify/schemaTypes/objects/module/gridItem.ts +0 -91
- package/templates/shopify/schemaTypes/objects/seo/description.tsx +0 -10
- package/templates/shopify/schemaTypes/objects/seo/home.tsx +0 -31
- package/templates/shopify/schemaTypes/objects/seo/page.tsx +0 -37
- package/templates/shopify/schemaTypes/objects/seo/shopify.tsx +0 -40
- package/templates/shopify/schemaTypes/singletons/home.ts +0 -62
- /package/lib/{dts/src/index.d.ts → index.d.mts} +0 -0
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "@sanity/cli",
|
3
|
-
"version": "3.36.
|
3
|
+
"version": "3.36.5-canary.34+48b8553cb5",
|
4
4
|
"description": "Sanity CLI tool for managing Sanity installations, managing plugins, schemas and datasets",
|
5
5
|
"keywords": [
|
6
6
|
"sanity",
|
@@ -22,24 +22,20 @@
|
|
22
22
|
},
|
23
23
|
"license": "MIT",
|
24
24
|
"author": "Sanity.io <hello@sanity.io>",
|
25
|
+
"sideEffects": false,
|
25
26
|
"exports": {
|
26
27
|
".": {
|
27
|
-
"types": "./lib/dts/src/index.d.ts",
|
28
28
|
"source": "./src/index.ts",
|
29
|
+
"import": "./lib/index.mjs",
|
29
30
|
"require": "./lib/index.js",
|
30
|
-
"
|
31
|
-
"module": "./lib/index.esm.js",
|
32
|
-
"import": "./lib/index.cjs.mjs"
|
33
|
-
},
|
34
|
-
"import": "./lib/index.esm.js",
|
35
|
-
"default": "./lib/index.esm.js"
|
31
|
+
"default": "./lib/index.js"
|
36
32
|
},
|
37
33
|
"./package.json": "./package.json"
|
38
34
|
},
|
39
35
|
"main": "./lib/index.js",
|
40
36
|
"module": "./lib/index.esm.js",
|
41
37
|
"source": "./src/index.ts",
|
42
|
-
"types": "./lib/
|
38
|
+
"types": "./lib/index.d.ts",
|
43
39
|
"bin": {
|
44
40
|
"sanity": "./bin/sanity"
|
45
41
|
},
|
@@ -51,26 +47,27 @@
|
|
51
47
|
"templates"
|
52
48
|
],
|
53
49
|
"scripts": {
|
54
|
-
"
|
55
|
-
"
|
56
|
-
"
|
57
|
-
"check:package": "pkg-utils --strict --tsconfig tsconfig.lib.json",
|
50
|
+
"build": "run-s clean && pkg-utils build --strict",
|
51
|
+
"check:package": "pkg-utils --strict",
|
52
|
+
"check:types": "tsc",
|
58
53
|
"clean": "rimraf lib",
|
59
54
|
"lint": "eslint .",
|
60
55
|
"test": "jest",
|
61
56
|
"ts": "node -r esbuild-register",
|
62
|
-
"watch": "pkg-utils watch
|
57
|
+
"watch": "pkg-utils watch"
|
63
58
|
},
|
64
59
|
"dependencies": {
|
65
60
|
"@babel/traverse": "^7.23.5",
|
66
|
-
"@sanity/
|
61
|
+
"@sanity/client": "^6.15.9",
|
62
|
+
"@sanity/codegen": "3.36.5-canary.34+48b8553cb5",
|
67
63
|
"@sanity/telemetry": "^0.7.6",
|
68
|
-
"@sanity/util": "3.36.
|
64
|
+
"@sanity/util": "3.36.5-canary.34+48b8553cb5",
|
69
65
|
"chalk": "^4.1.2",
|
66
|
+
"debug": "^4.3.4",
|
70
67
|
"decompress": "^4.2.0",
|
71
68
|
"esbuild": "^0.20.0",
|
72
69
|
"esbuild-register": "^3.4.1",
|
73
|
-
"get-it": "^8.4.
|
70
|
+
"get-it": "^8.4.17",
|
74
71
|
"golden-fleece": "^1.0.9",
|
75
72
|
"groq-js": "^1.7.0",
|
76
73
|
"node-machine-id": "^1.1.12",
|
@@ -80,11 +77,12 @@
|
|
80
77
|
},
|
81
78
|
"devDependencies": {
|
82
79
|
"@jest/globals": "^29.7.0",
|
80
|
+
"@repo/package.config": "0.0.0",
|
83
81
|
"@rexxars/gitconfiglocal": "^3.0.1",
|
84
82
|
"@rollup/plugin-node-resolve": "^15.2.3",
|
85
|
-
"@sanity/client": "^6.15.7",
|
86
83
|
"@sanity/eslint-config-studio": "^3.0.1",
|
87
84
|
"@sanity/generate-help-url": "^3.0.0",
|
85
|
+
"@sanity/types": "3.36.5-canary.34+48b8553cb5",
|
88
86
|
"@types/babel__traverse": "^7.20.5",
|
89
87
|
"@types/configstore": "^5.0.1",
|
90
88
|
"@types/cpx": "^1.5.2",
|
@@ -106,7 +104,6 @@
|
|
106
104
|
"clean-stack": "^3.0.0",
|
107
105
|
"configstore": "^5.0.1",
|
108
106
|
"cpx": "^1.5.0",
|
109
|
-
"debug": "^4.3.4",
|
110
107
|
"deep-sort-object": "^1.0.1",
|
111
108
|
"dotenv": "^16.0.3",
|
112
109
|
"dotenv-expand": "^9.0.0",
|
@@ -132,12 +129,12 @@
|
|
132
129
|
"semver": "^7.3.5",
|
133
130
|
"semver-compare": "^1.0.0",
|
134
131
|
"tar": "^6.1.11",
|
135
|
-
"vite": "^4.5.
|
132
|
+
"vite": "^4.5.3",
|
136
133
|
"which": "^2.0.2",
|
137
134
|
"xdg-basedir": "^4.0.0"
|
138
135
|
},
|
139
136
|
"engines": {
|
140
137
|
"node": ">=18"
|
141
138
|
},
|
142
|
-
"gitHead": "
|
139
|
+
"gitHead": "48b8553cb5172cc0d3eecca352cb4afa391bb29b"
|
143
140
|
}
|
@@ -12,6 +12,7 @@ import {colorInput} from '@sanity/color-input'
|
|
12
12
|
import {imageHotspotArrayPlugin} from 'sanity-plugin-hotspot-array'
|
13
13
|
import {media, mediaAssetSource} from 'sanity-plugin-media'
|
14
14
|
import {customDocumentActions} from './plugins/customDocumentActions'
|
15
|
+
import Navbar from './components/studio/Navbar'
|
15
16
|
|
16
17
|
const devOnlyPlugins = [visionTool()]
|
17
18
|
|
@@ -47,6 +48,12 @@ export default defineConfig({
|
|
47
48
|
},
|
48
49
|
},
|
49
50
|
},
|
51
|
+
|
52
|
+
studio: {
|
53
|
+
components: {
|
54
|
+
navbar: Navbar,
|
55
|
+
},
|
56
|
+
},
|
50
57
|
})`
|
51
58
|
|
52
59
|
const shopifyTemplate: ProjectTemplate = {
|
@@ -1,13 +1,13 @@
|
|
1
|
+
import {
|
2
|
+
type BaseSchemaDefinition,
|
3
|
+
type DocumentDefinition,
|
4
|
+
type ObjectDefinition,
|
5
|
+
} from '@sanity/types'
|
1
6
|
import fs from 'fs/promises'
|
2
7
|
import path from 'path'
|
3
8
|
import {format} from 'prettier'
|
4
9
|
import {Worker} from 'worker_threads'
|
5
10
|
|
6
|
-
import {
|
7
|
-
type BaseSchemaDefinition,
|
8
|
-
type DocumentDefinition,
|
9
|
-
type ObjectDefinition,
|
10
|
-
} from '../../../types'
|
11
11
|
import {type CliApiClient} from '../types'
|
12
12
|
import {getCliWorkerPath} from './cliWorker'
|
13
13
|
|
@@ -4,7 +4,7 @@ import React, {useState} from 'react'
|
|
4
4
|
import {Box, Text} from '@sanity/ui'
|
5
5
|
import Barcode from 'react-barcode'
|
6
6
|
import {MemberField} from 'sanity'
|
7
|
-
import styled from 'styled-components'
|
7
|
+
import {styled} from 'styled-components'
|
8
8
|
|
9
9
|
const BarcodeRoot = styled(Box)`
|
10
10
|
svg {
|
@@ -12,7 +12,7 @@ import {
|
|
12
12
|
useTheme,
|
13
13
|
} from '@sanity/ui'
|
14
14
|
import {CloseIcon} from '@sanity/icons'
|
15
|
-
import
|
15
|
+
import {css, styled} from 'styled-components'
|
16
16
|
|
17
17
|
const BlueColor = css`
|
18
18
|
color: ${({theme}) => theme.sanity.color.muted.primary.enabled.fg};
|
@@ -7,10 +7,8 @@
|
|
7
7
|
"strict": true,
|
8
8
|
"forceConsistentCasingInFileNames": true,
|
9
9
|
"noEmit": true,
|
10
|
-
"
|
11
|
-
"
|
12
|
-
"moduleResolution": "node",
|
13
|
-
"resolveJsonModule": true,
|
10
|
+
"module": "Preserve",
|
11
|
+
"moduleDetection": "force",
|
14
12
|
"isolatedModules": true,
|
15
13
|
"jsx": "preserve",
|
16
14
|
"incremental": true
|
@@ -1,6 +1,6 @@
|
|
1
1
|
# Sanity Studio for Shopify Projects
|
2
2
|
|
3
|
-
<
|
3
|
+
<img width="1072" alt="Sanity Studio with Shopify products" src="https://github.com/sanity-io/learn/assets/9684022/13aed6ff-a028-4c3f-bc4b-15bf9ba4c6ff">
|
4
4
|
|
5
5
|
## About
|
6
6
|
|
@@ -8,11 +8,11 @@ This Sanity Studio is configured for headless Shopify projects that use the offi
|
|
8
8
|
|
9
9
|
It contains examples of customizing your [structure][docs-structure], [document actions][docs-document-actions] and [input components][docs-input-components].
|
10
10
|
|
11
|
-
This studio can be used with
|
11
|
+
This studio can be used with any front end, or anywhere else you want your e-commerce content to go.
|
12
12
|
|
13
13
|
## Features
|
14
14
|
|
15
|
-
This studio comes
|
15
|
+
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.
|
16
16
|
|
17
17
|
It also comes with several convenient layout modules which can be re-used across various pages.
|
18
18
|
|
@@ -0,0 +1,29 @@
|
|
1
|
+
import {Box, Button, Card, Flex} from '@sanity/ui'
|
2
|
+
import type {NavbarProps} from 'sanity'
|
3
|
+
|
4
|
+
import {SHOPIFY_STORE_ID} from '../../constants'
|
5
|
+
import ShopifyIcon from '../icons/Shopify'
|
6
|
+
|
7
|
+
export default function Navbar(props: NavbarProps) {
|
8
|
+
if (!SHOPIFY_STORE_ID) return props.renderDefault(props)
|
9
|
+
|
10
|
+
return (
|
11
|
+
<Card>
|
12
|
+
<Flex align="center">
|
13
|
+
<Box flex={1}>{props.renderDefault(props)}</Box>
|
14
|
+
<Card paddingY={2} paddingRight={2} borderBottom={true}>
|
15
|
+
<Button
|
16
|
+
as="a"
|
17
|
+
href={`https://admin.shopify.com/store/${SHOPIFY_STORE_ID}`}
|
18
|
+
mode="bleed"
|
19
|
+
title="Open Shopify Admin"
|
20
|
+
target="_blank"
|
21
|
+
padding={1}
|
22
|
+
>
|
23
|
+
<ShopifyIcon />
|
24
|
+
</Button>
|
25
|
+
</Card>
|
26
|
+
</Flex>
|
27
|
+
</Card>
|
28
|
+
)
|
29
|
+
}
|
@@ -1,4 +1,8 @@
|
|
1
1
|
// Currency code (ISO 4217) to use when displaying prices in the studio
|
2
|
+
|
3
|
+
import ShopifyIcon from "./components/icons/Shopify"
|
4
|
+
import { ColorWheelIcon, ComposeIcon, SearchIcon } from '@sanity/icons'
|
5
|
+
|
2
6
|
// https://en.wikipedia.org/wiki/ISO_4217
|
3
7
|
export const DEFAULT_CURRENCY_CODE = 'USD'
|
4
8
|
|
@@ -26,6 +30,32 @@ export const PAGE_REFERENCES = [
|
|
26
30
|
export const SANITY_API_VERSION = '2022-10-25'
|
27
31
|
|
28
32
|
// Your Shopify store ID.
|
29
|
-
// This is your
|
33
|
+
// This is the ID in your Shopify admin URL (e.g. 'my-store-name' in https://admin.shopify.com/store/my-store-name).
|
34
|
+
// You only need to provide the ID, not the full URL.
|
30
35
|
// Set this to enable helper links in document status banners and shortcut links on products and collections.
|
31
36
|
export const SHOPIFY_STORE_ID = ''
|
37
|
+
|
38
|
+
// Field groups used through schema types
|
39
|
+
export const GROUPS = [
|
40
|
+
{
|
41
|
+
name: 'theme',
|
42
|
+
title: 'Theme',
|
43
|
+
icon: ColorWheelIcon,
|
44
|
+
},
|
45
|
+
{
|
46
|
+
default: true,
|
47
|
+
name: 'editorial',
|
48
|
+
title: 'Editorial',
|
49
|
+
icon: ComposeIcon
|
50
|
+
},
|
51
|
+
{
|
52
|
+
name: 'shopifySync',
|
53
|
+
title: 'Shopify sync',
|
54
|
+
icon: ShopifyIcon,
|
55
|
+
},
|
56
|
+
{
|
57
|
+
name: 'seo',
|
58
|
+
title: 'SEO',
|
59
|
+
icon: SearchIcon
|
60
|
+
},
|
61
|
+
]
|
@@ -73,7 +73,7 @@ Read more about [document actions][docs-document-actions].
|
|
73
73
|
|
74
74
|
`/plugins/customDocumentActions/shopifyDelete.tsx`
|
75
75
|
|
76
|
-
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
|
76
|
+
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.
|
77
77
|
|
78
78
|
### Edit in Shopify shortcut
|
79
79
|
|
@@ -96,12 +96,11 @@ A simple wrapper around a regular [string input](string-input) that uses the val
|
|
96
96
|
**Usage:**
|
97
97
|
|
98
98
|
```javascript
|
99
|
-
{
|
99
|
+
defineField({
|
100
100
|
name: 'title',
|
101
|
-
title: 'Title',
|
102
101
|
type: 'placeholderString',
|
103
102
|
options: { field: 'store.title' }
|
104
|
-
},
|
103
|
+
}),
|
105
104
|
```
|
106
105
|
|
107
106
|
### 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
|
|
129
128
|
**Usage**
|
130
129
|
|
131
130
|
```javascript
|
132
|
-
{
|
131
|
+
defineField({
|
133
132
|
title: 'Slug',
|
134
133
|
name: 'slugProxy',
|
135
134
|
type: 'proxyString',
|
136
|
-
options: {
|
137
|
-
}
|
135
|
+
options: {field: 'store.slug.current'},
|
136
|
+
})
|
138
137
|
```
|
139
138
|
|
140
139
|
### Shopify document status (preview component)
|
@@ -1,41 +1,19 @@
|
|
1
|
-
|
2
|
-
import {defineField, defineType} from 'sanity'
|
1
|
+
|
2
|
+
import {defineArrayMember, defineField, defineType} from 'sanity'
|
3
3
|
import {PackageIcon} from '@sanity/icons'
|
4
4
|
import {getExtension} from '@sanity/asset-utils'
|
5
5
|
import pluralize from 'pluralize-esm'
|
6
6
|
import CollectionHiddenInput from '../../components/inputs/CollectionHidden'
|
7
|
-
import ShopifyIcon from '../../components/icons/Shopify'
|
8
7
|
import ShopifyDocumentStatus from '../../components/media/ShopifyDocumentStatus'
|
8
|
+
import { GROUPS } from '../../constants'
|
9
9
|
|
10
|
-
const
|
11
|
-
{
|
12
|
-
name: 'theme',
|
13
|
-
title: 'Theme',
|
14
|
-
},
|
15
|
-
{
|
16
|
-
default: true,
|
17
|
-
name: 'editorial',
|
18
|
-
title: 'Editorial',
|
19
|
-
},
|
20
|
-
{
|
21
|
-
name: 'shopifySync',
|
22
|
-
title: 'Shopify sync',
|
23
|
-
icon: ShopifyIcon,
|
24
|
-
},
|
25
|
-
{
|
26
|
-
name: 'seo',
|
27
|
-
title: 'SEO',
|
28
|
-
},
|
29
|
-
]
|
30
|
-
|
31
|
-
export default defineType({
|
10
|
+
export const collectionType = defineType({
|
32
11
|
name: 'collection',
|
33
12
|
title: 'Collection',
|
34
13
|
type: 'document',
|
35
14
|
icon: PackageIcon,
|
36
15
|
groups: GROUPS,
|
37
16
|
fields: [
|
38
|
-
// Product hidden status
|
39
17
|
defineField({
|
40
18
|
name: 'hidden',
|
41
19
|
type: 'string',
|
@@ -47,29 +25,24 @@ export default defineType({
|
|
47
25
|
return !isDeleted
|
48
26
|
},
|
49
27
|
}),
|
50
|
-
// Title (proxy)
|
51
28
|
defineField({
|
52
29
|
name: 'titleProxy',
|
53
30
|
title: 'Title',
|
54
31
|
type: 'proxyString',
|
55
32
|
options: {field: 'store.title'},
|
56
33
|
}),
|
57
|
-
// Slug (proxy)
|
58
34
|
defineField({
|
59
35
|
name: 'slugProxy',
|
60
36
|
title: 'Slug',
|
61
37
|
type: 'proxyString',
|
62
38
|
options: {field: 'store.slug.current'},
|
63
39
|
}),
|
64
|
-
// Color theme
|
65
40
|
defineField({
|
66
41
|
name: 'colorTheme',
|
67
|
-
title: 'Color theme',
|
68
42
|
type: 'reference',
|
69
43
|
to: [{type: 'colorTheme'}],
|
70
44
|
group: 'theme',
|
71
45
|
}),
|
72
|
-
// Vector
|
73
46
|
defineField({
|
74
47
|
name: 'vector',
|
75
48
|
title: 'Vector artwork',
|
@@ -93,37 +66,30 @@ export default defineType({
|
|
93
66
|
return true
|
94
67
|
}),
|
95
68
|
}),
|
96
|
-
// Show hero
|
97
69
|
defineField({
|
98
70
|
name: 'showHero',
|
99
|
-
title: 'Show hero',
|
100
71
|
type: 'boolean',
|
101
72
|
description: 'If disabled, page title will be displayed instead',
|
102
73
|
group: 'editorial',
|
103
74
|
}),
|
104
|
-
// Hero
|
105
75
|
defineField({
|
106
76
|
name: 'hero',
|
107
|
-
|
108
|
-
type: 'hero.collection',
|
77
|
+
type: 'hero',
|
109
78
|
hidden: ({document}) => !document?.showHero,
|
110
79
|
group: 'editorial',
|
111
80
|
}),
|
112
|
-
// Modules
|
113
81
|
defineField({
|
114
82
|
name: 'modules',
|
115
|
-
title: 'Modules',
|
116
83
|
type: 'array',
|
117
84
|
description: 'Editorial modules to associate with this collection',
|
118
85
|
of: [
|
119
|
-
{type: '
|
120
|
-
{type: '
|
121
|
-
{type: '
|
122
|
-
{type: '
|
86
|
+
defineArrayMember({type: 'callout'}),
|
87
|
+
defineArrayMember({type: 'callToAction'}),
|
88
|
+
defineArrayMember({type: 'image'}),
|
89
|
+
defineArrayMember({type: 'instagram'}),
|
123
90
|
],
|
124
91
|
group: 'editorial',
|
125
92
|
}),
|
126
|
-
// Shopify collection
|
127
93
|
defineField({
|
128
94
|
name: 'store',
|
129
95
|
title: 'Shopify',
|
@@ -131,11 +97,10 @@ export default defineType({
|
|
131
97
|
description: 'Collection data from Shopify (read-only)',
|
132
98
|
group: 'shopifySync',
|
133
99
|
}),
|
134
|
-
// SEO
|
135
100
|
defineField({
|
136
101
|
name: 'seo',
|
137
102
|
title: 'SEO',
|
138
|
-
type: 'seo
|
103
|
+
type: 'seo',
|
139
104
|
group: 'seo',
|
140
105
|
}),
|
141
106
|
],
|
@@ -158,8 +123,7 @@ export default defineType({
|
|
158
123
|
rules: 'store.rules',
|
159
124
|
title: 'store.title',
|
160
125
|
},
|
161
|
-
prepare(
|
162
|
-
const {imageUrl, isDeleted, rules, title} = selection
|
126
|
+
prepare({imageUrl, isDeleted, rules, title}) {
|
163
127
|
const ruleCount = rules?.length || 0
|
164
128
|
|
165
129
|
return {
|
@@ -1,40 +1,27 @@
|
|
1
1
|
import {IceCreamIcon} from '@sanity/icons'
|
2
|
-
import React from 'react'
|
3
2
|
import {defineField, defineType} from 'sanity'
|
4
3
|
|
5
4
|
import ColorTheme from '../../components/media/ColorTheme'
|
6
5
|
|
7
|
-
export
|
6
|
+
export const colorThemeType = defineType({
|
8
7
|
name: 'colorTheme',
|
9
8
|
title: 'Color theme',
|
10
9
|
type: 'document',
|
11
10
|
icon: IceCreamIcon,
|
12
|
-
groups: [
|
13
|
-
{
|
14
|
-
name: 'shopifySync',
|
15
|
-
title: 'Shopify sync',
|
16
|
-
},
|
17
|
-
],
|
18
11
|
fields: [
|
19
|
-
// Title
|
20
12
|
defineField({
|
21
13
|
name: 'title',
|
22
|
-
title: 'Title',
|
23
14
|
type: 'string',
|
24
15
|
validation: (Rule) => Rule.required(),
|
25
16
|
}),
|
26
|
-
// Text color
|
27
17
|
defineField({
|
28
18
|
name: 'text',
|
29
|
-
title: 'Text',
|
30
19
|
type: 'color',
|
31
20
|
options: {disableAlpha: true},
|
32
21
|
validation: (Rule) => Rule.required(),
|
33
22
|
}),
|
34
|
-
// Background color
|
35
23
|
defineField({
|
36
24
|
name: 'background',
|
37
|
-
title: 'Background',
|
38
25
|
type: 'color',
|
39
26
|
options: {disableAlpha: true},
|
40
27
|
validation: (Rule) => Rule.required(),
|
@@ -46,9 +33,7 @@ export default defineType({
|
|
46
33
|
textColor: 'text.hex',
|
47
34
|
title: 'title',
|
48
35
|
},
|
49
|
-
prepare(
|
50
|
-
const {backgroundColor, textColor, title} = selection
|
51
|
-
|
36
|
+
prepare({backgroundColor, textColor, title}) {
|
52
37
|
return {
|
53
38
|
media: <ColorTheme background={backgroundColor} text={textColor} />,
|
54
39
|
subtitle: `${textColor || '(No color)'} / ${backgroundColor || '(No color)'}`,
|
@@ -2,94 +2,67 @@ import {DocumentIcon} from '@sanity/icons'
|
|
2
2
|
import {defineField} from 'sanity'
|
3
3
|
|
4
4
|
import {validateSlug} from '../../utils/validateSlug'
|
5
|
+
import { GROUPS } from '../../constants'
|
5
6
|
|
6
|
-
export
|
7
|
+
export const pageType = defineField({
|
7
8
|
name: 'page',
|
8
9
|
title: 'Page',
|
9
10
|
type: 'document',
|
10
11
|
icon: DocumentIcon,
|
11
|
-
groups:
|
12
|
-
{
|
13
|
-
name: 'theme',
|
14
|
-
title: 'Theme',
|
15
|
-
},
|
16
|
-
{
|
17
|
-
default: true,
|
18
|
-
name: 'editorial',
|
19
|
-
title: 'Editorial',
|
20
|
-
},
|
21
|
-
{
|
22
|
-
name: 'seo',
|
23
|
-
title: 'SEO',
|
24
|
-
},
|
25
|
-
],
|
12
|
+
groups: GROUPS,
|
26
13
|
fields: [
|
27
|
-
// Title
|
28
14
|
defineField({
|
29
15
|
name: 'title',
|
30
|
-
|
16
|
+
group: 'editorial',
|
31
17
|
type: 'string',
|
32
18
|
validation: (Rule) => Rule.required(),
|
33
19
|
}),
|
34
|
-
// Slug
|
35
20
|
defineField({
|
36
21
|
name: 'slug',
|
22
|
+
group: 'editorial',
|
37
23
|
type: 'slug',
|
38
24
|
options: {source: 'title'},
|
39
|
-
// @ts-ignore - TODO - fix this TS error
|
40
25
|
validation: validateSlug,
|
41
26
|
}),
|
42
|
-
// Color theme
|
43
27
|
defineField({
|
44
28
|
name: 'colorTheme',
|
45
|
-
title: 'Color theme',
|
46
29
|
type: 'reference',
|
47
30
|
to: [{type: 'colorTheme'}],
|
48
31
|
group: 'theme',
|
49
32
|
}),
|
50
|
-
// Show hero
|
51
33
|
defineField({
|
52
34
|
name: 'showHero',
|
53
|
-
title: 'Show hero',
|
54
35
|
type: 'boolean',
|
55
36
|
description: 'If disabled, page title will be displayed instead',
|
56
37
|
initialValue: false,
|
57
38
|
group: 'editorial',
|
58
39
|
}),
|
59
|
-
// Hero
|
60
40
|
defineField({
|
61
41
|
name: 'hero',
|
62
|
-
|
63
|
-
type: 'hero.page',
|
42
|
+
type: 'hero',
|
64
43
|
hidden: ({document}) => !document?.showHero,
|
65
44
|
group: 'editorial',
|
66
45
|
}),
|
67
|
-
// Body
|
68
46
|
defineField({
|
69
47
|
name: 'body',
|
70
|
-
|
71
|
-
type: 'body',
|
48
|
+
type: 'portableText',
|
72
49
|
group: 'editorial',
|
73
50
|
}),
|
74
|
-
// SEO
|
75
51
|
defineField({
|
76
52
|
name: 'seo',
|
77
53
|
title: 'SEO',
|
78
|
-
type: 'seo
|
54
|
+
type: 'seo',
|
79
55
|
group: 'seo',
|
80
56
|
}),
|
81
57
|
],
|
82
58
|
preview: {
|
83
59
|
select: {
|
84
|
-
active: 'active',
|
85
60
|
seoImage: 'seo.image',
|
86
61
|
title: 'title',
|
87
62
|
},
|
88
|
-
prepare(
|
89
|
-
const {seoImage, title} = selection
|
90
|
-
|
63
|
+
prepare({seoImage, title}) {
|
91
64
|
return {
|
92
|
-
media: seoImage,
|
65
|
+
media: seoImage ?? DocumentIcon,
|
93
66
|
title,
|
94
67
|
}
|
95
68
|
},
|