4
0
forked from crowetic/commerce
commerce/pages/index.tsx

35 lines
851 B
TypeScript
Raw Normal View History

2020-10-01 20:40:40 -05:00
import { GetStaticPropsContext, InferGetStaticPropsType } from 'next'
2020-10-02 14:51:36 -03: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>) {
return (
<>
<ProductGrid
products={[
...products,
...products,
...products,
...products,
...products,
...products,
]}
/>
<div>asdsasad</div>
<ProductGrid products={products.slice(3)} />
</>
)
2020-09-30 11:44:38 -05:00
}
2020-10-01 21:30:08 -05:00
Home.Layout = Layout