Merge branch 'custom-fields' of github.com:vercel/commerce into main

This commit is contained in:
Daniele Pancottini
2022-12-20 17:44:20 +01:00
24 changed files with 773 additions and 100 deletions

View File

@@ -3,11 +3,22 @@ import type {
GetStaticPropsContext,
InferGetStaticPropsType,
} from 'next'
import { useRouter } from 'next/router'
import commerce from '@lib/api/commerce'
import { useRouter } from 'next/router'
import { Layout } from '@components/common'
import { ProductView } from '@components/product'
// Used by the Shopify Example
const withMetafields = [
{ namespace: 'reviews', key: 'rating' },
{ namespace: 'reviews', key: 'count' },
{ namespace: 'my_fields', key: 'width' },
{ namespace: 'my_fields', key: 'weight' },
{ namespace: 'my_fields', key: 'length' },
]
export async function getStaticProps({
params,
locale,
@@ -18,7 +29,10 @@ export async function getStaticProps({
const pagesPromise = commerce.getAllPages({ config, preview })
const siteInfoPromise = commerce.getSiteInfo({ config, preview })
const productPromise = commerce.getProduct({
variables: { slug: params!.slug },
variables: {
slug: params!.slug,
withMetafields,
},
config,
preview,
})