mirror of
https://github.com/vercel/commerce.git
synced 2025-07-23 04:36:49 +00:00
Updates
This commit is contained in:
@@ -269,7 +269,7 @@ export const categoryQuery = `*[_type == "category" && slug.current == $slug &&
|
||||
}`;
|
||||
|
||||
// Categories query
|
||||
export const categoriesQuery = `*[_type == "category" && language == $locale] | order(title asc) {
|
||||
export const mainMenuQuery = `*[_type == "category" && language == $locale] | order(title asc) {
|
||||
_type,
|
||||
title,
|
||||
"slug": slug.current,
|
||||
|
@@ -7,9 +7,9 @@ import { draftMode } from 'next/headers'
|
||||
|
||||
import { revalidateSecret } from './sanity.api'
|
||||
|
||||
import { categoryQuery, homePageQuery, pageQuery, productQuery, searchPageQuery } from './queries'
|
||||
import { categoryQuery, homePageQuery, mainMenuQuery, pageQuery, productQuery, searchPageQuery } from './queries'
|
||||
|
||||
import { CategoryPayload, HomePagePayload, PagePayload, ProductPayload, SearchPayload } from './sanity.types'
|
||||
import { CategoryPayload, HomePagePayload, MainMenuPayload, PagePayload, ProductPayload, SearchPayload } from './sanity.types'
|
||||
|
||||
export const token = process.env.SANITY_API_READ_TOKEN
|
||||
|
||||
@@ -56,7 +56,7 @@ export function getHomePage(locale: string) {
|
||||
return sanityFetch<HomePagePayload | null>({
|
||||
query: homePageQuery,
|
||||
params: { locale },
|
||||
tags: ['home', 'products', 'categories', 'page'],
|
||||
tags: ['home', 'products', 'categories', 'page', 'menu'],
|
||||
})
|
||||
}
|
||||
|
||||
@@ -90,4 +90,12 @@ export function getSearch(slug: string, locale: string) {
|
||||
params: { slug, locale },
|
||||
tags: ['search'],
|
||||
})
|
||||
}
|
||||
|
||||
export function getMainMenu(locale: string) {
|
||||
return sanityFetch<MainMenuPayload | null>({
|
||||
query: mainMenuQuery,
|
||||
params: { locale },
|
||||
tags: ['menu'],
|
||||
})
|
||||
}
|
@@ -58,4 +58,10 @@ export interface SearchPayload {
|
||||
description?: string;
|
||||
image: Image
|
||||
}
|
||||
}
|
||||
|
||||
export interface MainMenuPayload {
|
||||
title?: string
|
||||
_type?: string
|
||||
items: []
|
||||
}
|
@@ -3,6 +3,7 @@ import { isDev, SanityDocument } from 'sanity'
|
||||
import { localStorefrontPreviewUrl, publicStorefrontPreviewUrl } from '../constants'
|
||||
|
||||
const SANITY_STUDIO_API_READ_TOKEN = "skYG2HXNga8uxSL7rFIreJEnP0SdVjCZ2nzB8rUHD4wRWxXPGceXTuR5vCVBP99mWZ9ULhghmpUyX7EtzDmJusSk6Gwvdr3nLAsdWI9ZktIWvSWUNpHbu0Xfrrt0UUaktrLglk7ToABvjXlaPHLpOIR3dnjl4MGByutPmyra0b5t20kgDrmF"
|
||||
|
||||
// Customise this function to show the correct URL based on the current document
|
||||
export default async function getPreviewUrl(doc: SanityDocument) {
|
||||
|
||||
|
Reference in New Issue
Block a user