Skip to content

Instantly share code, notes, and snippets.

@serifcolakel
Created February 21, 2022 19:20
Show Gist options
  • Save serifcolakel/01c939cb0ad3140e609070ec7ad0a8cb to your computer and use it in GitHub Desktop.
Save serifcolakel/01c939cb0ad3140e609070ec7ad0a8cb to your computer and use it in GitHub Desktop.
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