Created
February 21, 2022 19:20
-
-
Save serifcolakel/01c939cb0ad3140e609070ec7ad0a8cb to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import React from "react"; | |
import ProductPageContent from "../../components/ProductPageContent"; | |
import { getProduct, getAllProducts } from "../../lib/shopify"; | |
export default function ProductPage({ product }) { | |
return ( | |
<div className="min-h-screen py-12 sm:pt-20"> | |
<ProductPageContent product={product} /> | |
</div> | |
); | |
} | |
export async function getStaticPaths() { | |
const products = await getAllProducts(); | |
const paths = products.map((item) => { | |
const product = String(item.node.handle); | |
return { | |
params: { product }, | |
}; | |
}); | |
return { | |
paths: paths, | |
fallback: false, | |
}; | |
} | |
export async function getStaticProps({ params }) { | |
const product = await getProduct(params.product); | |
return { | |
props: { product }, | |
}; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment