diff --git a/framework/shopify/api/operations/get-site-info.ts b/framework/shopify/api/operations/get-site-info.ts index 27b63b0f9..7f51d1d5c 100644 --- a/framework/shopify/api/operations/get-site-info.ts +++ b/framework/shopify/api/operations/get-site-info.ts @@ -35,9 +35,9 @@ export default function getSiteInfoOperation({ } = {}): Promise { const cfg = commerce.getConfig(config) - const categories = await getCategories(cfg) - const brands = await getBrands(cfg) - /* + const categoriesPromise = getCategories(cfg) + const brandsPromise = getBrands(cfg) + /* const { fetch, locale } = cfg const { data } = await fetch( query, @@ -53,8 +53,8 @@ export default function getSiteInfoOperation({ */ return { - categories, - brands, + categories: await categoriesPromise, + brands: await brandsPromise, } } diff --git a/framework/swell/common/get-site-info.ts b/framework/swell/common/get-site-info.ts index c7a06c52e..a6b8aa46a 100644 --- a/framework/swell/common/get-site-info.ts +++ b/framework/swell/common/get-site-info.ts @@ -19,8 +19,10 @@ const getSiteInfo = async (options?: { config = getConfig(config) - const categories = await getCategories(config) - const brands = await getVendors(config) + const categoriesPromise = getCategories(config) + const brandsPromise = getVendors(config) + const categories = await categoriesPromise + const brands = await brandsPromise return { categories, diff --git a/pages/[...pages].tsx b/pages/[...pages].tsx index c63963ef6..9e564a50b 100644 --- a/pages/[...pages].tsx +++ b/pages/[...pages].tsx @@ -16,8 +16,10 @@ export async function getStaticProps({ locales, }: GetStaticPropsContext<{ pages: string[] }>) { const config = { locale, locales } - const { pages } = await commerce.getAllPages({ config, preview }) - const { categories } = await commerce.getSiteInfo({ config, preview }) + const pagesPromise = commerce.getAllPages({ config, preview }) + const siteInfoPromise = commerce.getSiteInfo({ config, preview }) + const { pages } = await pagesPromise + const { categories } = await siteInfoPromise const path = params?.pages.join('/') const slug = locale ? `${locale}/${path}` : path const pageItem = pages.find((p) => (p.url ? getSlug(p.url) === slug : false)) diff --git a/pages/cart.tsx b/pages/cart.tsx index d01664873..c0b15dfd5 100644 --- a/pages/cart.tsx +++ b/pages/cart.tsx @@ -13,8 +13,10 @@ export async function getStaticProps({ locales, }: GetStaticPropsContext) { const config = { locale, locales } - const { pages } = await commerce.getAllPages({ config, preview }) - const { categories } = await commerce.getSiteInfo({ config, preview }) + const pagesPromise = commerce.getAllPages({ config, preview }) + const siteInfoPromise = commerce.getSiteInfo({ config, preview }) + const { pages } = await pagesPromise + const { categories } = await siteInfoPromise return { props: { pages, categories }, } diff --git a/pages/index.tsx b/pages/index.tsx index 05f694814..e5aab20b1 100644 --- a/pages/index.tsx +++ b/pages/index.tsx @@ -11,13 +11,16 @@ export async function getStaticProps({ locales, }: GetStaticPropsContext) { const config = { locale, locales } - const { products } = await commerce.getAllProducts({ + const productsPromise = commerce.getAllProducts({ variables: { first: 6 }, config, preview, }) - const { categories, brands } = await commerce.getSiteInfo({ config, preview }) - const { pages } = await commerce.getAllPages({ config, preview }) + const pagesPromise = commerce.getAllPages({ config, preview }) + const siteInfoPromise = commerce.getSiteInfo({ config, preview }) + const { products } = await productsPromise + const { pages } = await pagesPromise + const { categories, brands } = await siteInfoPromise return { props: { diff --git a/pages/orders.tsx b/pages/orders.tsx index 7a744b2cd..b8b10814b 100644 --- a/pages/orders.tsx +++ b/pages/orders.tsx @@ -10,8 +10,10 @@ export async function getStaticProps({ locales, }: GetStaticPropsContext) { const config = { locale, locales } - const { pages } = await commerce.getAllPages({ config, preview }) - const { categories } = await commerce.getSiteInfo({ config, preview }) + const pagesPromise = commerce.getAllPages({ config, preview }) + const siteInfoPromise = commerce.getSiteInfo({ config, preview }) + const { pages } = await pagesPromise + const { categories } = await siteInfoPromise return { props: { pages, categories }, diff --git a/pages/product/[slug].tsx b/pages/product/[slug].tsx index 3988705fe..8d56961a9 100644 --- a/pages/product/[slug].tsx +++ b/pages/product/[slug].tsx @@ -15,20 +15,23 @@ export async function getStaticProps({ preview, }: GetStaticPropsContext<{ slug: string }>) { const config = { locale, locales } - const { pages } = await commerce.getAllPages({ config, preview }) - const { categories } = await commerce.getSiteInfo({ config, preview }) - - const { product } = await commerce.getProduct({ + const pagesPromise = commerce.getAllPages({ config, preview }) + const siteInfoPromise = commerce.getSiteInfo({ config, preview }) + const productPromise = commerce.getProduct({ variables: { slug: params!.slug }, config, preview, }) - const { products: relatedProducts } = await commerce.getAllProducts({ + const allProductsPromise = commerce.getAllProducts({ variables: { first: 4 }, config, preview, }) + const { pages } = await pagesPromise + const { categories } = await siteInfoPromise + const { product } = await productPromise + const { products: relatedProducts } = await allProductsPromise if (!product) { throw new Error(`Product with slug '${params!.slug}' not found`) diff --git a/pages/profile.tsx b/pages/profile.tsx index 1f575c8f2..eb54004ee 100644 --- a/pages/profile.tsx +++ b/pages/profile.tsx @@ -10,8 +10,10 @@ export async function getStaticProps({ locales, }: GetStaticPropsContext) { const config = { locale, locales } - const { pages } = await commerce.getAllPages({ config, preview }) - const { categories } = await commerce.getSiteInfo({ config, preview }) + const pagesPromise = commerce.getAllPages({ config, preview }) + const siteInfoPromise = commerce.getSiteInfo({ config, preview }) + const { pages } = await pagesPromise + const { categories } = await siteInfoPromise return { props: { pages, categories }, diff --git a/pages/wishlist.tsx b/pages/wishlist.tsx index bd558c393..fd28edff4 100644 --- a/pages/wishlist.tsx +++ b/pages/wishlist.tsx @@ -20,8 +20,10 @@ export async function getStaticProps({ } const config = { locale, locales } - const { pages } = await commerce.getAllPages({ config, preview }) - const { categories } = await commerce.getSiteInfo({ config, preview }) + const pagesPromise = commerce.getAllPages({ config, preview }) + const siteInfoPromise = commerce.getSiteInfo({ config, preview }) + const { pages } = await pagesPromise + const { categories } = await siteInfoPromise return { props: {