diff --git a/pages/[...pages].tsx b/pages/[...pages].tsx index a4b4485a6..c46563a7b 100644 --- a/pages/[...pages].tsx +++ b/pages/[...pages].tsx @@ -1,4 +1,5 @@ import type { GetStaticPropsContext, InferGetStaticPropsType } from 'next' +import { getConfig } from '@lib/bigcommerce/api' import getPage from '@lib/bigcommerce/api/operations/get-page' import getAllPages from '@lib/bigcommerce/api/operations/get-all-pages' import getSlug from '@utils/get-slug' @@ -9,13 +10,15 @@ export async function getStaticProps({ params, locale, }: GetStaticPropsContext<{ pages: string[] }>) { - const { pages } = await getAllPages({ preview }) + const config = getConfig({ locale }) + const { pages } = await getAllPages({ preview, config }) const path = params?.pages.join('/') const slug = locale ? `${locale}/${path}` : path const pageItem = pages.find((p) => (p.url ? getSlug(p.url) === slug : false)) const data = - pageItem && (await getPage({ variables: { id: pageItem.id! }, preview })) + pageItem && + (await getPage({ variables: { id: pageItem.id! }, config, preview })) const page = data?.page if (!page) { diff --git a/pages/blog.tsx b/pages/blog.tsx index c6cd1ccb8..cc2cd87c0 100644 --- a/pages/blog.tsx +++ b/pages/blog.tsx @@ -1,10 +1,15 @@ import type { GetStaticPropsContext } from 'next' +import { getConfig } from '@lib/bigcommerce/api' import getAllPages from '@lib/bigcommerce/api/operations/get-all-pages' import { Layout } from '@components/core' import { Container } from '@components/ui' -export async function getStaticProps({ preview }: GetStaticPropsContext) { - const { pages } = await getAllPages({ preview }) +export async function getStaticProps({ + preview, + locale, +}: GetStaticPropsContext) { + const config = getConfig({ locale }) + const { pages } = await getAllPages({ config, preview }) return { props: { pages }, } diff --git a/pages/cart.tsx b/pages/cart.tsx index 14d7e9745..1938fde28 100644 --- a/pages/cart.tsx +++ b/pages/cart.tsx @@ -1,4 +1,5 @@ import type { GetStaticPropsContext } from 'next' +import { getConfig } from '@lib/bigcommerce/api' import getAllPages from '@lib/bigcommerce/api/operations/get-all-pages' import { Layout } from '@components/core' import { Button } from '@components/ui' @@ -8,8 +9,12 @@ import usePrice from '@lib/bigcommerce/use-price' import { CartItem } from '@components/cart' import { Text } from '@components/ui' -export async function getStaticProps({ preview }: GetStaticPropsContext) { - const { pages } = await getAllPages({ preview }) +export async function getStaticProps({ + preview, + locale, +}: GetStaticPropsContext) { + const config = getConfig({ locale }) + const { pages } = await getAllPages({ config, preview }) return { props: { pages }, } diff --git a/pages/orders.tsx b/pages/orders.tsx index f2b463428..a92546f12 100644 --- a/pages/orders.tsx +++ b/pages/orders.tsx @@ -1,11 +1,16 @@ import type { GetStaticPropsContext } from 'next' +import { getConfig } from '@lib/bigcommerce/api' import getAllPages from '@lib/bigcommerce/api/operations/get-all-pages' import { Layout } from '@components/core' import { Container, Text } from '@components/ui' import { Bag } from '@components/icons' -export async function getStaticProps({ preview }: GetStaticPropsContext) { - const { pages } = await getAllPages({ preview }) +export async function getStaticProps({ + preview, + locale, +}: GetStaticPropsContext) { + const config = getConfig({ locale }) + const { pages } = await getAllPages({ config, preview }) return { props: { pages }, } diff --git a/pages/profile.tsx b/pages/profile.tsx index d2babd9eb..94219e52c 100644 --- a/pages/profile.tsx +++ b/pages/profile.tsx @@ -1,11 +1,16 @@ import type { GetStaticPropsContext } from 'next' +import { getConfig } from '@lib/bigcommerce/api' import getAllPages from '@lib/bigcommerce/api/operations/get-all-pages' import useCustomer from '@lib/bigcommerce/use-customer' import { Layout } from '@components/core' import { Container, Text } from '@components/ui' -export async function getStaticProps({ preview }: GetStaticPropsContext) { - const { pages } = await getAllPages({ preview }) +export async function getStaticProps({ + preview, + locale, +}: GetStaticPropsContext) { + const config = getConfig({ locale }) + const { pages } = await getAllPages({ config, preview }) return { props: { pages }, } diff --git a/pages/search.tsx b/pages/search.tsx index c6db8108f..2e0cd8511 100644 --- a/pages/search.tsx +++ b/pages/search.tsx @@ -2,12 +2,14 @@ import cn from 'classnames' import type { GetStaticPropsContext, InferGetStaticPropsType } from 'next' import Link from 'next/link' import { useRouter } from 'next/router' +import { getConfig } from '@lib/bigcommerce/api' +import getAllPages from '@lib/bigcommerce/api/operations/get-all-pages' +import getSiteInfo from '@lib/bigcommerce/api/operations/get-site-info' +import useSearch from '@lib/bigcommerce/products/use-search' import { Layout } from '@components/core' import { ProductCard } from '@components/product' import { Container, Grid, Skeleton } from '@components/ui' -import useSearch from '@lib/bigcommerce/products/use-search' -import getAllPages from '@lib/bigcommerce/api/operations/get-all-pages' -import getSiteInfo from '@lib/bigcommerce/api/operations/get-site-info' + import rangeMap from '@lib/range-map' import getSlug from '@utils/get-slug' import { @@ -17,9 +19,13 @@ import { useSearchMeta, } from '@utils/search' -export async function getStaticProps({ preview }: GetStaticPropsContext) { - const { pages } = await getAllPages({ preview }) - const { categories, brands } = await getSiteInfo({ preview }) +export async function getStaticProps({ + preview, + locale, +}: GetStaticPropsContext) { + const config = getConfig({ locale }) + const { pages } = await getAllPages({ config, preview }) + const { categories, brands } = await getSiteInfo({ config, preview }) return { props: { pages, categories, brands }, diff --git a/pages/wishlist.tsx b/pages/wishlist.tsx index a27e26312..66c453fa6 100644 --- a/pages/wishlist.tsx +++ b/pages/wishlist.tsx @@ -1,4 +1,5 @@ import type { GetStaticPropsContext } from 'next' +import { getConfig } from '@lib/bigcommerce/api' import getAllPages from '@lib/bigcommerce/api/operations/get-all-pages' import useWishlist from '@lib/bigcommerce/wishlist/use-wishlist' import { Layout } from '@components/core' @@ -6,9 +7,12 @@ import { Heart } from '@components/icons' import { Container, Text } from '@components/ui' import { WishlistCard } from '@components/wishlist' -export async function getStaticProps({ preview }: GetStaticPropsContext) { - const { pages } = await getAllPages({ preview }) - +export async function getStaticProps({ + preview, + locale, +}: GetStaticPropsContext) { + const config = getConfig({ locale }) + const { pages } = await getAllPages({ config, preview }) return { props: { pages }, }