2020-10-01 20:40:40 -05:00
|
|
|
import { GetStaticPropsContext, InferGetStaticPropsType } from 'next'
|
2020-10-03 04:17:41 -05:00
|
|
|
import getAllProducts from '@lib/bigcommerce/api/operations/get-all-products'
|
2020-10-01 20:40:40 -05:00
|
|
|
import { Layout } from '@components/core'
|
|
|
|
import { ProductGrid } from '@components/product'
|
2020-09-30 13:36:02 -05:00
|
|
|
|
|
|
|
export async function getStaticProps({ preview }: GetStaticPropsContext) {
|
2020-10-01 20:40:40 -05:00
|
|
|
const { products } = await getAllProducts()
|
2020-09-30 13:36:02 -05:00
|
|
|
return {
|
2020-10-02 12:59:50 -03:00
|
|
|
props: { products: products.slice(0, 6) },
|
2020-10-01 20:40:40 -05:00
|
|
|
}
|
2020-09-30 13:36:02 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
export default function Home({
|
|
|
|
products,
|
|
|
|
}: InferGetStaticPropsType<typeof getStaticProps>) {
|
2020-10-01 21:30:08 -05:00
|
|
|
return <ProductGrid products={products} />
|
2020-09-30 11:44:38 -05:00
|
|
|
}
|
2020-10-01 21:30:08 -05:00
|
|
|
|
|
|
|
Home.Layout = Layout
|