_app.tsx 704 B

1234567891011121314151617181920212223
  1. import type { ReactElement, ReactNode } from "react";
  2. import type { NextPage } from "next";
  3. import type { AppProps } from "next/app";
  4. import Layout from "../components/common/Layout";
  5. import "../styles/globals.scss";
  6. export type NextPageWithLayout<P = {}, IP = P> = NextPage<P, IP> & {
  7. getLayout?: (page: ReactElement) => ReactNode;
  8. };
  9. type AppPropsWithLayout = AppProps & {
  10. Component: NextPageWithLayout;
  11. };
  12. function defaultGetLayout(page: ReactElement): ReactNode {
  13. return <Layout>{page}</Layout>;
  14. }
  15. export default function MyApp({ Component, pageProps }: AppPropsWithLayout) {
  16. const getLayout = Component.getLayout ?? defaultGetLayout;
  17. return getLayout(<Component {...pageProps} />);
  18. }