add product route, separate layouts between home & pages

This commit is contained in:
andr-ew 2023-06-21 18:53:04 -05:00
parent c174b6ad79
commit f0187e9f7a
7 changed files with 45 additions and 9 deletions

14
app/(home)/layout.js Normal file
View File

@ -0,0 +1,14 @@
import { TypesNav } from '/components/home.js';
export default function HomeLayout({ children }) {
return (
<>
<header>
<nav>
<TypesNav />
</nav>
</header>
<main>{children}</main>
</>
);
}

12
app/(page)/layout.js Normal file
View File

@ -0,0 +1,12 @@
export default function ProductLayout({ children }) {
return (
<>
{/* <header> */}
{/* <nav> */}
{/* <a>back</a> */}
{/* </nav> */}
{/* </header> */}
<main>{children}</main>
</>
);
}

View File

@ -0,0 +1,17 @@
import { getProducts } from 'lib/shopify';
export async function generateStaticParams() {
const products = await getProducts({
sortKey: 'UPDATED_AT',
reverse: false,
query: '',
});
console.log({ products });
return products.map(product => ({ product: product.handle }));
}
export default async function ProductPage({ params: { handle } }) {
return <h1>{handle}</h1>;
}

View File

@ -1,14 +1,7 @@
import { TypesNav } from '/components/home.js';
export default function RootLayout({ children }) {
return (
<html lang='en'>
<body>
<nav>
<TypesNav />
</nav>
<main>{children}</main>
</body>
<body>{children}</body>
</html>
);
}

View File

@ -61,7 +61,7 @@ export async function HomeProduct({ product }) {
const collections = product?.collections?.nodes;
return (
<Link href={`/${product?.handle}`}>
<Link href={`/product/${product?.handle}`}>
<Image
src={featuredImage?.url}
alt={featuredImage?.altText}