From 6313975dedb6087a642bebf8299e59766d4c61a5 Mon Sep 17 00:00:00 2001 From: Kevin Green Date: Sun, 24 Sep 2023 15:38:23 -0700 Subject: [PATCH] product landing added to sanity --- cms/desk/index.js | 12 +++ cms/schemas/documents/productLanding.js | 97 +++++++++++++++++++++++++ cms/schemas/index.js | 5 ++ 3 files changed, 114 insertions(+) create mode 100644 cms/schemas/documents/productLanding.js diff --git a/cms/desk/index.js b/cms/desk/index.js index 850ba5b..5613060 100644 --- a/cms/desk/index.js +++ b/cms/desk/index.js @@ -178,6 +178,17 @@ export const structure = (S, context) => { .params({type: 'colorType'}), ); + const productLandingsMenuItem = S.listItem() + .title('Product Landings') + .icon() + .child( + S.documentList() + .title('Product Landings') + .menuItems(S.documentTypeList('productLanding').getMenuItems()) + .filter('_type == $type') + .params({type: 'productLanding'}), + ); + const productsMenuItem = S.listItem() .title('Shopify Products') .icon() @@ -196,6 +207,7 @@ export const structure = (S, context) => { S.list() .title('Products') .items([ + productLandingsMenuItem, S.divider(), productsMenuItem, variantsMenuItem, diff --git a/cms/schemas/documents/productLanding.js b/cms/schemas/documents/productLanding.js new file mode 100644 index 0000000..05fea34 --- /dev/null +++ b/cms/schemas/documents/productLanding.js @@ -0,0 +1,97 @@ +import {TagIcon} from '@sanity/icons' +import {defineField, defineType} from 'sanity' + +const GROUPS = [ + { + name: 'editorial', + title: 'Editorial', + default: true, + }, + { + name: 'extendedProducts', + title: 'Extended products', + }, + { + name: 'seo', + title: 'SEO', + }, +] + +export default defineType({ + name: 'productLanding', + title: 'Product Landing', + type: 'document', + icon: TagIcon, + groups: GROUPS, + fields: [ + + // Title (proxy) + defineField({ + name: 'title', + title: 'Title', + type: 'string', + group: 'editorial', + }), + + defineField({ + name: 'slug', + ttile: 'Slug', + type: 'slug', + options: { + source: 'title', + maxLength: 96, + }, + group: 'editorial', + }), + + defineField({ + name: 'productReference', + type: 'reference', + to: {type: 'product'}, + group: 'editorial', + }), + + + defineField({ + name: 'body', + title: 'Body', + type: 'richText', + group: 'editorial', + }), + defineField({ + name: 'modules', + title: 'Modules', + type: 'productComponentList', + group: 'editorial', + }), + + defineField({ + name: 'associatedProducts', + title: 'Associated products', + type: 'array', + of: [{type: 'reference', to: [{type: 'product'}]}], + group: 'extendedProducts', + }), + + + defineField({ + name: 'seo', + title: 'SEO', + type: 'seo', + group: 'seo', + }), + ], + preview: { + select: { + title: 'title', + }, + prepare(selection) { + const { title } = selection + + return { + // subtitle, + title, + } + }, + }, +}) diff --git a/cms/schemas/index.js b/cms/schemas/index.js index c40200d..f626833 100644 --- a/cms/schemas/index.js +++ b/cms/schemas/index.js @@ -18,6 +18,8 @@ import home from './documents/home' import page from './documents/page' import faq from './documents/faq' import product from './documents/product' + +import productLanding from './documents/productLanding' import productVariant from './documents/productVariant' import theme from './documents/theme' @@ -28,6 +30,7 @@ const documents = [ page, faq, product, + productLanding, productVariant, theme ] @@ -97,6 +100,8 @@ import shopifyProduct from './objects/shopifyProduct' import shopifyProductVariant from './objects/shopifyProductVariant' import shopifyProductVariantOptionValue from './objects/shopifyProductVariantOptionValue' + + const objects = [ customProductOptionColor, customProductOptionSize,