diff --git a/pages/blog.tsx b/pages/blog.tsx index 1a66c47ff..523b94d74 100644 --- a/pages/blog.tsx +++ b/pages/blog.tsx @@ -1,10 +1,12 @@ import { GetStaticPropsContext, InferGetStaticPropsType } from 'next' +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() return { - props: {}, + props: { pages }, } } diff --git a/pages/cart.tsx b/pages/cart.tsx index aa3e7fc35..59f278ee0 100644 --- a/pages/cart.tsx +++ b/pages/cart.tsx @@ -1,15 +1,12 @@ import { GetStaticPropsContext, InferGetStaticPropsType } from 'next' -import getAllProducts from '@lib/bigcommerce/api/operations/get-all-products' +import getAllPages from '@lib/bigcommerce/api/operations/get-all-pages' import { Layout } from '@components/core' import { Container } from '@components/ui' -import getSiteInfo from '@lib/bigcommerce/api/operations/get-site-info' export async function getStaticProps({ preview }: GetStaticPropsContext) { - const { products } = await getAllProducts() - const { categories, brands } = await getSiteInfo() - + const { pages } = await getAllPages() return { - props: { products, categories, brands }, + props: { pages }, } } diff --git a/pages/product/[slug].tsx b/pages/product/[slug].tsx index 600727066..94acc2445 100644 --- a/pages/product/[slug].tsx +++ b/pages/product/[slug].tsx @@ -1,5 +1,6 @@ import { GetStaticPropsContext, InferGetStaticPropsType } from 'next' import { useRouter } from 'next/router' +import getAllPages from '@lib/bigcommerce/api/operations/get-all-pages' import getProduct from '@lib/bigcommerce/api/operations/get-product' import { Layout } from '@components/core' import { ProductView } from '@components/product' @@ -8,6 +9,7 @@ import getAllProductPaths from '@lib/bigcommerce/api/operations/get-all-product- export async function getStaticProps({ params, }: GetStaticPropsContext<{ slug: string }>) { + const { pages } = await getAllPages() const { product } = await getProduct({ variables: { slug: params!.slug } }) if (!product) { @@ -15,9 +17,7 @@ export async function getStaticProps({ } return { - props: { - product, - }, + props: { pages, product }, revalidate: 200, } } diff --git a/pages/search.tsx b/pages/search.tsx index 513f814ae..51f927acc 100644 --- a/pages/search.tsx +++ b/pages/search.tsx @@ -2,6 +2,7 @@ import { GetStaticPropsContext, InferGetStaticPropsType } from 'next' import { useRouter } from 'next/router' import Link from 'next/link' import cn from 'classnames' +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' @@ -17,10 +18,11 @@ import { import { range } from 'lodash' export async function getStaticProps({ preview }: GetStaticPropsContext) { + const { pages } = await getAllPages() const { categories, brands } = await getSiteInfo() return { - props: { categories, brands }, + props: { pages, categories, brands }, } } diff --git a/pages/wishlist.tsx b/pages/wishlist.tsx index f337ebe1f..549648097 100644 --- a/pages/wishlist.tsx +++ b/pages/wishlist.tsx @@ -1,5 +1,5 @@ import { GetStaticPropsContext, InferGetStaticPropsType } from 'next' -import getAllProducts from '@lib/bigcommerce/api/operations/get-all-products' +import getAllPages from '@lib/bigcommerce/api/operations/get-all-pages' import { Layout } from '@components/core' import { Container } from '@components/ui' import { WishlistCard } from '@components/wishlist' @@ -7,11 +7,11 @@ import { WishlistCard } from '@components/wishlist' import getSiteInfo from '@lib/bigcommerce/api/operations/get-site-info' export async function getStaticProps({ preview }: GetStaticPropsContext) { - const { products } = await getAllProducts() + const { pages } = await getAllPages() const { categories, brands } = await getSiteInfo() return { - props: { products, categories, brands }, + props: { pages, categories, brands }, } }