mirror of
https://github.com/vercel/commerce.git
synced 2025-07-27 04:01:23 +00:00
Shopify Provier Updates (#212)
* changes * Adding shopify commit * Changed to query page by id * Fixed page query, Changed use-search GraphQl query * Update use-search.tsx * remove unused util * Changed cookie expiration * Update tsconfig.json Co-authored-by: okbel <curciobel@gmail.com>
This commit is contained in:
@@ -3,33 +3,32 @@ import getPageQuery from '../utils/queries/get-page-query'
|
||||
import { Page } from './get-all-pages'
|
||||
|
||||
type Variables = {
|
||||
slug: string
|
||||
id: string
|
||||
}
|
||||
|
||||
type ReturnType = {
|
||||
page: Page
|
||||
}
|
||||
export type GetPageResult<T extends { page?: any } = { page?: Page }> = T
|
||||
|
||||
const getPage = async (options: {
|
||||
variables: Variables
|
||||
config: ShopifyConfig
|
||||
preview?: boolean
|
||||
}): Promise<ReturnType> => {
|
||||
}): Promise<GetPageResult> => {
|
||||
let { config, variables } = options ?? {}
|
||||
|
||||
config = getConfig(config)
|
||||
const { locale } = config
|
||||
|
||||
const { data } = await config.fetch(getPageQuery, {
|
||||
variables,
|
||||
})
|
||||
|
||||
const { pageByHandle: page } = data
|
||||
const page = data.node
|
||||
|
||||
return {
|
||||
page: page
|
||||
? {
|
||||
...page,
|
||||
name: page.title,
|
||||
url: page?.handle,
|
||||
url: `/${locale}/${page.handle}`,
|
||||
}
|
||||
: null,
|
||||
}
|
||||
|
Reference in New Issue
Block a user