mirror of
https://github.com/vercel/commerce.git
synced 2025-07-22 20:26:49 +00:00
Added shared layout with _app
This commit is contained in:
@@ -1,6 +1,15 @@
|
||||
import { FC } from 'react'
|
||||
import type { AppProps } from 'next/app'
|
||||
import '@assets/global.css'
|
||||
|
||||
const Noop: FC = ({ children }) => <>{children}</>
|
||||
|
||||
export default function MyApp({ Component, pageProps }: AppProps) {
|
||||
return <Component {...pageProps} />
|
||||
const Layout = (Component as any).Layout || Noop
|
||||
|
||||
return (
|
||||
<Layout>
|
||||
<Component {...pageProps} />
|
||||
</Layout>
|
||||
)
|
||||
}
|
||||
|
@@ -14,9 +14,7 @@ export default function Home({
|
||||
products,
|
||||
}: InferGetStaticPropsType<typeof getStaticProps>) {
|
||||
console.log('PRODUCTS', products)
|
||||
return (
|
||||
<Layout>
|
||||
<ProductGrid products={products} />
|
||||
</Layout>
|
||||
)
|
||||
return <ProductGrid products={products} />
|
||||
}
|
||||
|
||||
Home.Layout = Layout
|
||||
|
@@ -43,7 +43,7 @@ export async function getStaticPaths() {
|
||||
}
|
||||
}
|
||||
|
||||
export default function Home({
|
||||
export default function Slug({
|
||||
product,
|
||||
productData,
|
||||
}: InferGetStaticPropsType<typeof getStaticProps>) {
|
||||
@@ -51,13 +51,11 @@ export default function Home({
|
||||
|
||||
const router = useRouter()
|
||||
|
||||
return (
|
||||
<Layout>
|
||||
{router.isFallback ? (
|
||||
<h1>Loading...</h1>
|
||||
) : (
|
||||
<ProductView productData={productData} />
|
||||
)}
|
||||
</Layout>
|
||||
return router.isFallback ? (
|
||||
<h1>Loading...</h1>
|
||||
) : (
|
||||
<ProductView productData={productData} />
|
||||
)
|
||||
}
|
||||
|
||||
Slug.Layout = Layout
|
||||
|
Reference in New Issue
Block a user