mirror of
https://github.com/vercel/commerce.git
synced 2025-05-18 15:36:58 +00:00
parallelize requests
This commit is contained in:
parent
bb9cfa0cd1
commit
4e6c1628a6
@ -1,4 +1,4 @@
|
||||
import { useKeenSlider } from 'keen-slider/react'
|
||||
import { useKeenSlider } from 'keen-slider/react.esm.js'
|
||||
import React, {
|
||||
Children,
|
||||
FC,
|
||||
|
@ -1,6 +1,6 @@
|
||||
.swatch {
|
||||
box-sizing: border-box;
|
||||
composes: root from 'components/ui/Button/Button.module.css';
|
||||
composes: root from '@components/ui/Button/Button.module.css';
|
||||
@apply h-10 w-10 bg-primary text-primary rounded-full mr-3 inline-flex
|
||||
items-center justify-center cursor-pointer transition duration-150 ease-in-out
|
||||
p-0 shadow-none border-gray-200 border box-border;
|
||||
|
@ -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,
|
||||
|
@ -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))
|
||||
|
@ -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 },
|
||||
}
|
||||
|
@ -16,8 +16,10 @@ export async function getStaticProps({
|
||||
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 { pages } = await pagesPromise
|
||||
const { categories, brands } = await siteInfoPromise
|
||||
|
||||
return {
|
||||
props: {
|
||||
|
@ -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 },
|
||||
|
@ -15,19 +15,22 @@ 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`)
|
||||
|
@ -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 },
|
||||
|
@ -36,8 +36,11 @@ export async function getStaticProps({
|
||||
locales,
|
||||
}: GetStaticPropsContext) {
|
||||
const config = { locale, locales }
|
||||
const { pages } = await commerce.getAllPages({ config, preview })
|
||||
const { categories, brands } = await commerce.getSiteInfo({ config, preview })
|
||||
const pagesPromise = commerce.getAllPages({ config, preview })
|
||||
const siteInfoPromise = commerce.getSiteInfo({ config, preview })
|
||||
const { pages } = await pagesPromise
|
||||
const { categories, brands } = await siteInfoPromise
|
||||
|
||||
return {
|
||||
props: {
|
||||
pages,
|
||||
|
@ -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: {
|
||||
|
Loading…
x
Reference in New Issue
Block a user