Skip to content

Instantly share code, notes, and snippets.

@serifcolakel
Created February 21, 2022 19:54
Show Gist options
  • Save serifcolakel/7fa4c3cc1ecc5a5b226200318d9b56e3 to your computer and use it in GitHub Desktop.
Save serifcolakel/7fa4c3cc1ecc5a5b226200318d9b56e3 to your computer and use it in GitHub Desktop.
import styles from "../styles/Home.module.css";
import { getProductsInCollection } from "../lib/shopify";
// object destructuring to get the data from the query -> products
export default function Home({ products }) {
console.log(products);
return <div className={styles.container}>You are in the home Page</div>;
}
// this is the query that will be used to get the data from the shopify store
export async function getStaticProps() {
const products = await getProductsInCollection();
return {
// this is the data that will be passed to the component as props
props: { products },
};
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment