use layouts
This commit is contained in:
parent
2f42885fbd
commit
09f1dbd607
1 changed files with 15 additions and 2 deletions
|
@ -1,6 +1,19 @@
|
||||||
import "../styles/globals.css";
|
import "../styles/globals.css";
|
||||||
|
import type { ReactElement, ReactNode } from "react";
|
||||||
|
import type { NextPage } from "next";
|
||||||
import type { AppProps } from "next/app";
|
import type { AppProps } from "next/app";
|
||||||
|
|
||||||
export default function App({ Component, pageProps }: AppProps) {
|
export type NextPageWithLayout<P = {}, IP = P> = NextPage<P, IP> & {
|
||||||
return <Component {...pageProps} />;
|
getLayout?: (page: ReactElement) => ReactNode;
|
||||||
|
};
|
||||||
|
|
||||||
|
type AppPropsWithLayout = AppProps & {
|
||||||
|
Component: NextPageWithLayout;
|
||||||
|
};
|
||||||
|
|
||||||
|
export default function App({ Component, pageProps }: AppPropsWithLayout) {
|
||||||
|
// Use the layout defined at the page level, if available
|
||||||
|
const getLayout = Component.getLayout ?? ((page) => page);
|
||||||
|
|
||||||
|
return getLayout(<Component {...pageProps} />);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue