Skip to content

Commit

Permalink
sanity theme + promo bar
Browse files Browse the repository at this point in the history
  • Loading branch information
iamkevingreen committed Sep 18, 2023
1 parent eb5e698 commit aca8a1b
Show file tree
Hide file tree
Showing 3 changed files with 41 additions and 4 deletions.
7 changes: 5 additions & 2 deletions app/queries/sanity.js
Original file line number Diff line number Diff line change
Expand Up @@ -283,9 +283,12 @@ export const QUERY_PAGE = (slug) => groq`*[
}`

export const QUERY_HOME = groq`
*[_type == 'home' &&
*[_type == 'theme' &&
launchDate <= now() &&
!(_id in path("drafts.**"))] {
${homeQuery}
homepage-> {
${homeQuery}
}
}[0]
`

4 changes: 3 additions & 1 deletion app/routes/($locale)._index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,9 @@ import PageComponentList from '~/components/PageComponentList'

export async function loader({context}) {

const sanityPage = await context.sanity.fetch(QUERY_HOME)
const sanityData = await context.sanity.fetch(QUERY_HOME)
console.log('sanityData', sanityData)
const sanityPage = sanityData.homepage
// console.log('sanity page', sanityPage)

const productIds = []
Expand Down
34 changes: 33 additions & 1 deletion cms/schemas/documents/theme.js
Original file line number Diff line number Diff line change
@@ -1,33 +1,56 @@
import React from 'react'
import Emoji from 'a11y-react-emoji'

import {defineField} from 'sanity'

const Icon = () => <Emoji style={{fontSize: '1.25em'}} symbol="🏡" />

export default {
name: 'theme',
title: 'Theme',
icon: Icon,
type: 'document',
groups: [
{
name: 'theme',
default: true,
title: 'Theme',
},
{
name: 'promo',
title: 'Promo',
}
],
fields: [
{
name: 'themeTitle',
type: 'string',
title: 'Theme Title',
group: 'theme',
},
{
name: 'launchDate',
type: 'date',
title: 'Launch Date',
description: 'Select the date you want to launch the site.',
group: 'theme',
},
{
name: 'homepage',
title: 'Homepage',
description: 'Select the page you want to be the homepage on the marketing site.',
type: 'reference',
to: [{type: 'page'}],
to: [{type: 'home'}],
validation: Rule => Rule.required(),
group: 'theme',
},
{
name: 'headerMenu',
title: 'Header Menu',
description: 'Build complex menus from the menu area, assign them here to update the menu everywhere',
type: 'reference',
to: { type: 'header' },
group: 'theme',
// validation: Rule => Rule.required()
},
{
Expand All @@ -36,6 +59,7 @@ export default {
description: 'Build complex menus from the module area, assign them here to update the menu everywhere',
type: 'reference',
to: { type: 'footer' },
group: 'theme',
// validation: Rule => Rule.required()
},
{
Expand All @@ -44,8 +68,16 @@ export default {
description: 'Create custom carts in preparation for high volume experiences, or merchandise difference products across storefronts.',
type: 'reference',
to: { type: 'cart' },
group: 'theme',
// validation: Rule => Rule.required()
},
defineField({
name: 'promo',
title: 'Promo',
description: 'globally display promo content',
type: 'string',
group: 'promo',
})
],
preview: {
select: {
Expand Down

0 comments on commit aca8a1b

Please sign in to comment.