diff --git a/apps/web/components/layout.tsx b/apps/web/components/layout.tsx new file mode 100644 index 000000000..f01410c4c --- /dev/null +++ b/apps/web/components/layout.tsx @@ -0,0 +1,15 @@ +import React, { ReactNode } from "react"; + +interface Props { + children?: any; +} + +export default function Layout({ children }: Props) { + return ( + <> +
Header
+
{children}
+
Footer
+ + ); +} diff --git a/apps/web/pages/_app.tsx b/apps/web/pages/_app.tsx index c055f25c2..6e36e5af3 100644 --- a/apps/web/pages/_app.tsx +++ b/apps/web/pages/_app.tsx @@ -1,6 +1,16 @@ -import '../styles/globals.css' -import type { AppProps } from 'next/app' +import { ReactElement, ReactNode } from "react"; +import type { AppProps } from "next/app"; +import { NextPage } from "next"; -export default function App({ Component, pageProps }: AppProps) { - return +export type NextPageWithLayout

= NextPage & { + getLayout?: (page: ReactElement) => ReactNode; +}; + +type AppPropsWithLayout = AppProps & { + Component: NextPageWithLayout; +}; + +export default function App({ Component, pageProps }: AppPropsWithLayout) { + const getLayout = Component.getLayout || ((page: any) => page); + return getLayout(); } diff --git a/apps/web/pages/index.tsx b/apps/web/pages/index.tsx index e2509bdf1..944b2d135 100644 --- a/apps/web/pages/index.tsx +++ b/apps/web/pages/index.tsx @@ -1,77 +1,13 @@ -import Head from "next/head"; -import Image from "next/image"; -import styles from "../styles/Home.module.css"; +import type { ReactElement } from "react"; +import Layout from "../components/layout"; +import type { NextPageWithLayout } from "./_app"; -export async function getStaticProps(context: any) { - return { - props: {}, // will be passed to the page component as props - }; -} +const Page: NextPageWithLayout = () => { + return

hello world

; +}; -export default function Home() { - return ( -
- - Create Next App - - - +Page.getLayout = function getLayout(page: ReactElement) { + return {page}; +}; -
-

- Welcome to Next.js! -

- -

- Get started by editing{" "} - pages/index.tsx -

- -
- -

Documentation →

-

Find in-depth information about Next.js features and API.

-
- - -

Learn →

-

Learn about Next.js in an interactive course with quizzes!

-
- - -

Examples →

-

Discover and deploy boilerplate example Next.js projects.

-
- - -

Deploy →

-

- Instantly deploy your Next.js site to a public URL with Vercel. -

-
-
-
- - -
- ); -} +export default Page;