Moved getAllPages everywhere

This commit is contained in:
Luis Alvarez 2021-05-21 15:06:21 -05:00
parent 066a53d52d
commit 9794d5e626
8 changed files with 24 additions and 25 deletions

View File

@ -1,6 +1,6 @@
import type { GetStaticPropsContext } from 'next'
import { getConfig } from '@framework/api'
import getAllPages from '@framework/common/get-all-pages'
import commerce from '@lib/api/commerce'
import { Layout } from '@components/common'
import { Container } from '@components/ui'
@ -9,7 +9,7 @@ export async function getStaticProps({
locale,
}: GetStaticPropsContext) {
const config = getConfig({ locale })
const { pages } = await getAllPages({ config, preview })
const { pages } = await commerce.getAllPages({ config, preview })
return {
props: { pages },
}

View File

@ -1,8 +1,8 @@
import type { GetStaticPropsContext } from 'next'
import { getConfig } from '@framework/api'
import getAllPages from '@framework/common/get-all-pages'
import useCart from '@framework/cart/use-cart'
import usePrice from '@framework/product/use-price'
import commerce from '@lib/api/commerce'
import { Layout } from '@components/common'
import { Button, Text } from '@components/ui'
import { Bag, Cross, Check, MapPin, CreditCard } from '@components/icons'
@ -13,7 +13,7 @@ export async function getStaticProps({
locale,
}: GetStaticPropsContext) {
const config = getConfig({ locale })
const { pages } = await getAllPages({ config, preview })
const { pages } = await commerce.getAllPages({ config, preview })
return {
props: { pages },
}

View File

@ -1,3 +1,4 @@
import commerce from '@lib/api/commerce'
import { Layout } from '@components/common'
import { Grid, Marquee, Hero } from '@components/ui'
import { ProductCard } from '@components/product'
@ -7,7 +8,6 @@ import type { GetStaticPropsContext, InferGetStaticPropsType } from 'next'
import { getConfig } from '@framework/api'
import getAllProducts from '@framework/product/get-all-products'
import getSiteInfo from '@framework/common/get-site-info'
import getAllPages from '@framework/common/get-all-pages'
export async function getStaticProps({
preview,
@ -22,7 +22,7 @@ export async function getStaticProps({
})
const { categories, brands } = await getSiteInfo({ config, preview })
const { pages } = await getAllPages({ config, preview })
const { pages } = await commerce.getAllPages({ config, preview })
return {
props: {

View File

@ -1,16 +1,16 @@
import type { GetStaticPropsContext } from 'next'
import commerce from '@lib/api/commerce'
import { Bag } from '@components/icons'
import { Layout } from '@components/common'
import { Container, Text } from '@components/ui'
import { getConfig } from '@framework/api'
import getAllPages from '@framework/common/get-all-pages'
export async function getStaticProps({
preview,
locale,
}: GetStaticPropsContext) {
const config = getConfig({ locale })
const { pages } = await getAllPages({ config, preview })
const { pages } = await commerce.getAllPages({ config, preview })
return {
props: { pages },
}

View File

@ -4,12 +4,12 @@ import type {
InferGetStaticPropsType,
} from 'next'
import { useRouter } from 'next/router'
import commerce from '@lib/api/commerce'
import { Layout } from '@components/common'
import { ProductView } from '@components/product'
import { getConfig } from '@framework/api'
import getProduct from '@framework/product/get-product'
import getAllPages from '@framework/common/get-all-pages'
import getAllProductPaths from '@framework/product/get-all-product-paths'
export async function getStaticProps({
@ -18,7 +18,7 @@ export async function getStaticProps({
preview,
}: GetStaticPropsContext<{ slug: string }>) {
const config = getConfig({ locale })
const { pages } = await getAllPages({ config, preview })
const { pages } = await commerce.getAllPages({ config, preview })
const { product } = await getProduct({
variables: { slug: params!.slug },
config,

View File

@ -1,7 +1,7 @@
import type { GetStaticPropsContext } from 'next'
import { getConfig } from '@framework/api'
import getAllPages from '@framework/common/get-all-pages'
import useCustomer from '@framework/customer/use-customer'
import commerce from '@lib/api/commerce'
import { Layout } from '@components/common'
import { Container, Text } from '@components/ui'
@ -10,7 +10,7 @@ export async function getStaticProps({
locale,
}: GetStaticPropsContext) {
const config = getConfig({ locale })
const { pages } = await getAllPages({ config, preview })
const { pages } = await commerce.getAllPages({ config, preview })
return {
props: { pages },
}

View File

@ -10,11 +10,18 @@ import { Container, Grid, Skeleton } from '@components/ui'
import { getConfig } from '@framework/api'
import useSearch from '@framework/product/use-search'
import getAllPages from '@framework/common/get-all-pages'
import getSiteInfo from '@framework/common/get-site-info'
import commerce from '@lib/api/commerce'
import rangeMap from '@lib/range-map'
import {
filterQuery,
getCategoryPath,
getDesignerPath,
useSearchMeta,
} from '@lib/search'
import { Product } from '@commerce/types'
// TODO(bc) Remove this. This should come from the API
import getSlug from '@lib/get-slug'
@ -26,20 +33,12 @@ const SORT = Object.entries({
'price-desc': 'Price: High to low',
})
import {
filterQuery,
getCategoryPath,
getDesignerPath,
useSearchMeta,
} from '@lib/search'
import { Product } from '@commerce/types'
export async function getStaticProps({
preview,
locale,
}: GetStaticPropsContext) {
const config = getConfig({ locale })
const { pages } = await getAllPages({ config, preview })
const { pages } = await commerce.getAllPages({ config, preview })
const { categories, brands } = await getSiteInfo({ config, preview })
return {
props: {

View File

@ -1,4 +1,5 @@
import type { GetStaticPropsContext } from 'next'
import commerce from '@lib/api/commerce'
import { Heart } from '@components/icons'
import { Layout } from '@components/common'
import { Text, Container } from '@components/ui'
@ -7,7 +8,6 @@ import { getConfig } from '@framework/api'
import { useCustomer } from '@framework/customer'
import { WishlistCard } from '@components/wishlist'
import useWishlist from '@framework/wishlist/use-wishlist'
import getAllPages from '@framework/common/get-all-pages'
export async function getStaticProps({
preview,
@ -21,7 +21,7 @@ export async function getStaticProps({
}
const config = getConfig({ locale })
const { pages } = await getAllPages({ config, preview })
const { pages } = await commerce.getAllPages({ config, preview })
return {
props: {
pages,