mirror of
https://github.com/vercel/commerce.git
synced 2025-07-04 20:21:21 +00:00
Remove 'spree' prefix from isomorphicConfig and add lastUpdatedProductsPrerenderCount
This commit is contained in:
parent
7d5a63bbf4
commit
ed49ac8833
@ -13,3 +13,4 @@ NEXT_PUBLIC_SPREE_ALLOWED_IMAGE_DOMAIN=localhost
|
|||||||
NEXT_PUBLIC_SPREE_CATEGORIES_TAXONOMY_ID=1
|
NEXT_PUBLIC_SPREE_CATEGORIES_TAXONOMY_ID=1
|
||||||
NEXT_PUBLIC_SPREE_BRANDS_TAXONOMY_ID=27
|
NEXT_PUBLIC_SPREE_BRANDS_TAXONOMY_ID=27
|
||||||
NEXT_PUBLIC_SPREE_SHOW_SINGLE_VARIANT_OPTIONS=false
|
NEXT_PUBLIC_SPREE_SHOW_SINGLE_VARIANT_OPTIONS=false
|
||||||
|
NEXT_PUBLIC_SPREE_LAST_UPDATED_PRODUCTS_PRERENDER_COUNT=10
|
||||||
|
@ -93,7 +93,7 @@ export default function getSiteInfoOperation({
|
|||||||
SpreeSdkVariables
|
SpreeSdkVariables
|
||||||
>('__UNUSED__', {
|
>('__UNUSED__', {
|
||||||
variables: createVariables(
|
variables: createVariables(
|
||||||
requireConfigValue('spreeCategoriesTaxonomyId') as string
|
requireConfigValue('categoriesTaxonomyId') as string
|
||||||
),
|
),
|
||||||
})
|
})
|
||||||
|
|
||||||
@ -106,7 +106,7 @@ export default function getSiteInfoOperation({
|
|||||||
SpreeSdkVariables
|
SpreeSdkVariables
|
||||||
>('__UNUSED__', {
|
>('__UNUSED__', {
|
||||||
variables: createVariables(
|
variables: createVariables(
|
||||||
requireConfigValue('spreeBrandsTaxonomyId') as string
|
requireConfigValue('brandsTaxonomyId') as string
|
||||||
),
|
),
|
||||||
})
|
})
|
||||||
|
|
||||||
|
@ -20,7 +20,7 @@ const createApiFetch: (
|
|||||||
_getConfig
|
_getConfig
|
||||||
) => {
|
) => {
|
||||||
const client = makeClient({
|
const client = makeClient({
|
||||||
host: requireConfigValue('spreeApiHost') as string,
|
host: requireConfigValue('apiHost') as string,
|
||||||
fetcherType: 'custom',
|
fetcherType: 'custom',
|
||||||
createFetcher: (fetcherOptions) => {
|
createFetcher: (fetcherOptions) => {
|
||||||
return createCustomizedFetchFetcher({
|
return createCustomizedFetchFetcher({
|
||||||
|
@ -15,7 +15,7 @@ import type { GraphQLFetcherResult } from '@commerce/api'
|
|||||||
import createCustomizedFetchFetcher from './utils/create-customized-fetch-fetcher'
|
import createCustomizedFetchFetcher from './utils/create-customized-fetch-fetcher'
|
||||||
|
|
||||||
const client = makeClient({
|
const client = makeClient({
|
||||||
host: requireConfigValue('spreeApiHost') as string,
|
host: requireConfigValue('apiHost') as string,
|
||||||
fetcherType: 'custom',
|
fetcherType: 'custom',
|
||||||
createFetcher: (fetcherOptions) => {
|
createFetcher: (fetcherOptions) => {
|
||||||
return createCustomizedFetchFetcher({
|
return createCustomizedFetchFetcher({
|
||||||
|
@ -1,34 +1,38 @@
|
|||||||
import forceIsomorphicConfigValues from './utils/force-isomorphic-config-values'
|
import forceIsomorphicConfigValues from './utils/force-isomorphic-config-values'
|
||||||
import requireConfig from './utils/require-config'
|
import requireConfig from './utils/require-config'
|
||||||
import validateCookieExpire from './utils/validate-cookie-expire'
|
import validateCookieExpire from './utils/validate-cookie-expire'
|
||||||
|
import validateProductsPrerenderCount from './utils/validate-products-prerender-count'
|
||||||
|
|
||||||
const isomorphicConfig = {
|
const isomorphicConfig = {
|
||||||
spreeApiHost: process.env.NEXT_PUBLIC_SPREE_API_HOST,
|
apiHost: process.env.NEXT_PUBLIC_SPREE_API_HOST,
|
||||||
defaultLocale: process.env.NEXT_PUBLIC_SPREE_DEFAULT_LOCALE,
|
defaultLocale: process.env.NEXT_PUBLIC_SPREE_DEFAULT_LOCALE,
|
||||||
cartCookieName: process.env.NEXT_PUBLIC_SPREE_CART_COOKIE_NAME,
|
cartCookieName: process.env.NEXT_PUBLIC_SPREE_CART_COOKIE_NAME,
|
||||||
cartCookieExpire: validateCookieExpire(
|
cartCookieExpire: validateCookieExpire(
|
||||||
process.env.NEXT_PUBLIC_SPREE_CART_COOKIE_EXPIRE
|
process.env.NEXT_PUBLIC_SPREE_CART_COOKIE_EXPIRE
|
||||||
),
|
),
|
||||||
spreeImageHost: process.env.NEXT_PUBLIC_SPREE_IMAGE_HOST,
|
imageHost: process.env.NEXT_PUBLIC_SPREE_IMAGE_HOST,
|
||||||
spreeCategoriesTaxonomyId:
|
categoriesTaxonomyId: process.env.NEXT_PUBLIC_SPREE_CATEGORIES_TAXONOMY_ID,
|
||||||
process.env.NEXT_PUBLIC_SPREE_CATEGORIES_TAXONOMY_ID,
|
brandsTaxonomyId: process.env.NEXT_PUBLIC_SPREE_BRANDS_TAXONOMY_ID,
|
||||||
spreeBrandsTaxonomyId: process.env.NEXT_PUBLIC_SPREE_BRANDS_TAXONOMY_ID,
|
|
||||||
showSingleVariantOptions:
|
showSingleVariantOptions:
|
||||||
process.env.NEXT_PUBLIC_SPREE_SHOW_SINGLE_VARIANT_OPTIONS === 'true',
|
process.env.NEXT_PUBLIC_SPREE_SHOW_SINGLE_VARIANT_OPTIONS === 'true',
|
||||||
|
lastUpdatedProductsPrerenderCount: validateProductsPrerenderCount(
|
||||||
|
process.env.NEXT_PUBLIC_SPREE_LAST_UPDATED_PRODUCTS_PRERENDER_COUNT
|
||||||
|
),
|
||||||
}
|
}
|
||||||
|
|
||||||
export default forceIsomorphicConfigValues(
|
export default forceIsomorphicConfigValues(
|
||||||
isomorphicConfig,
|
isomorphicConfig,
|
||||||
[],
|
[],
|
||||||
[
|
[
|
||||||
'spreeApiHost',
|
'apiHost',
|
||||||
'defaultLocale',
|
'defaultLocale',
|
||||||
'cartCookieName',
|
'cartCookieName',
|
||||||
'cartCookieExpire',
|
'cartCookieExpire',
|
||||||
'spreeImageHost',
|
'imageHost',
|
||||||
'spreeCategoriesTaxonomyId',
|
'categoriesTaxonomyId',
|
||||||
'spreeBrandsTaxonomyId',
|
'brandsTaxonomyId',
|
||||||
'showSingleVariantOptions',
|
'showSingleVariantOptions',
|
||||||
|
'lastUpdatedProductsPrerenderCount',
|
||||||
]
|
]
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -54,7 +54,7 @@ const normalizeVariant = (
|
|||||||
|
|
||||||
const variantImage = getMediaGallery(
|
const variantImage = getMediaGallery(
|
||||||
spreeVariantImageRecords,
|
spreeVariantImageRecords,
|
||||||
createGetAbsoluteImageUrl(requireConfigValue('spreeImageHost') as string)
|
createGetAbsoluteImageUrl(requireConfigValue('imageHost') as string)
|
||||||
)[0]
|
)[0]
|
||||||
|
|
||||||
if (variantImage) {
|
if (variantImage) {
|
||||||
@ -68,7 +68,7 @@ const normalizeVariant = (
|
|||||||
|
|
||||||
const productImage = getMediaGallery(
|
const productImage = getMediaGallery(
|
||||||
spreeProductImageRecords,
|
spreeProductImageRecords,
|
||||||
createGetAbsoluteImageUrl(requireConfigValue('spreeImageHost') as string)
|
createGetAbsoluteImageUrl(requireConfigValue('imageHost') as string)
|
||||||
)[0]
|
)[0]
|
||||||
|
|
||||||
lineItemImage = productImage
|
lineItemImage = productImage
|
||||||
|
@ -28,7 +28,7 @@ const normalizeProduct = (
|
|||||||
|
|
||||||
const images = getMediaGallery(
|
const images = getMediaGallery(
|
||||||
spreeImageRecords,
|
spreeImageRecords,
|
||||||
createGetAbsoluteImageUrl(requireConfigValue('spreeImageHost') as string)
|
createGetAbsoluteImageUrl(requireConfigValue('imageHost') as string)
|
||||||
)
|
)
|
||||||
|
|
||||||
const price: ProductPrice = {
|
const price: ProductPrice = {
|
||||||
|
@ -1,8 +1,8 @@
|
|||||||
const validateCookieExpire = (expire: unknown) => {
|
const validateCookieExpire = (expire: unknown): number => {
|
||||||
let expireInteger: number
|
let expireInteger: number
|
||||||
|
|
||||||
if (typeof expire === 'string') {
|
if (typeof expire === 'string') {
|
||||||
expireInteger = parseFloat(expire || '')
|
expireInteger = parseFloat(expire)
|
||||||
} else if (typeof expire === 'number') {
|
} else if (typeof expire === 'number') {
|
||||||
expireInteger = expire
|
expireInteger = expire
|
||||||
} else {
|
} else {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user