Skip to content

Commit

Permalink
product landing added to sanity
Browse files Browse the repository at this point in the history
  • Loading branch information
iamkevingreen committed Sep 24, 2023
1 parent e09c58b commit 6313975
Show file tree
Hide file tree
Showing 3 changed files with 114 additions and 0 deletions.
12 changes: 12 additions & 0 deletions cms/desk/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand All @@ -196,6 +207,7 @@ export const structure = (S, context) => {
S.list()
.title('Products')
.items([
productLandingsMenuItem,
S.divider(),
productsMenuItem,
variantsMenuItem,
Expand Down
97 changes: 97 additions & 0 deletions cms/schemas/documents/productLanding.js
Original file line number Diff line number Diff line change
@@ -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,
}
},
},
})
5 changes: 5 additions & 0 deletions cms/schemas/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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'

Expand All @@ -28,6 +30,7 @@ const documents = [
page,
faq,
product,
productLanding,
productVariant,
theme
]
Expand Down Expand Up @@ -97,6 +100,8 @@ import shopifyProduct from './objects/shopifyProduct'
import shopifyProductVariant from './objects/shopifyProductVariant'
import shopifyProductVariantOptionValue from './objects/shopifyProductVariantOptionValue'



const objects = [
customProductOptionColor,
customProductOptionSize,
Expand Down

0 comments on commit 6313975

Please sign in to comment.