From 99c0166a40f5051abf9f703b538e19951642ff09 Mon Sep 17 00:00:00 2001 From: Guillaume Dorce Date: Thu, 11 May 2023 21:14:28 +0200 Subject: [PATCH] move header and footer in components, and layout in layouts/Home --- src/components/Footer.tsx | 41 ++++++++++++++ src/components/Header.tsx | 39 +++++++++++++ src/layouts/Home.tsx | 38 +++++++++++++ src/pages/index.tsx | 114 +------------------------------------- tsconfig.json | 5 +- 5 files changed, 123 insertions(+), 114 deletions(-) create mode 100644 src/components/Footer.tsx create mode 100644 src/components/Header.tsx create mode 100644 src/layouts/Home.tsx diff --git a/src/components/Footer.tsx b/src/components/Footer.tsx new file mode 100644 index 0000000..959781f --- /dev/null +++ b/src/components/Footer.tsx @@ -0,0 +1,41 @@ +import Link from "next/link"; +import Image from "next/image"; +import { FaGithub } from "react-icons/fa"; + +export default function Footer() { + return ( + + ); +} + diff --git a/src/components/Header.tsx b/src/components/Header.tsx new file mode 100644 index 0000000..5bc4b6b --- /dev/null +++ b/src/components/Header.tsx @@ -0,0 +1,39 @@ +import Link from "next/link"; +import Image from "next/image"; + +export default function Header() { + return ( +
+ + My Site Logo + + +
+ ); +} diff --git a/src/layouts/Home.tsx b/src/layouts/Home.tsx new file mode 100644 index 0000000..d3395e6 --- /dev/null +++ b/src/layouts/Home.tsx @@ -0,0 +1,38 @@ +import Head from "next/head"; +import Header from "@/components/Header"; +import Footer from "@/components/Footer"; + +export default function Layout({ children, title }: { children: React.ReactNode, title?: string }) { + const newTitle = title ? title + " | " : ""; + return ( +
+ + {newTitle + "Photo Club Haute Lozère"} + + + + + + + + + + + + + + + + + + + + + +
+
{children}
+
+
+ ); +} + diff --git a/src/pages/index.tsx b/src/pages/index.tsx index cfd9194..b413bdc 100644 --- a/src/pages/index.tsx +++ b/src/pages/index.tsx @@ -1,115 +1,5 @@ import Image from "next/image"; -import Link from "next/link"; -import Head from "next/head"; -import { FaGithub } from "react-icons/fa"; - -function Header() { - return ( -
- - My Site Logo - - -
- ); -} - -function Footer() { - return ( - - ); -} - -function Layout({ children, title }: { children: React.ReactNode, title?: string }) { - const newTitle = title ? title + " | " : ""; - return ( -
- - {newTitle + "Photo Club Haute Lozère"} - - - - - - - - - - - - - - - - - - - - - -
-
{children}
-
- ); -} +import Layout from "@/layouts/Home"; function Home() { return ( @@ -190,5 +80,3 @@ function Home() { } export default Home; - -export { Layout }; diff --git a/tsconfig.json b/tsconfig.json index 658068a..7db101f 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -14,7 +14,10 @@ "isolatedModules": true, "jsx": "preserve", "incremental": true, - "noUncheckedIndexedAccess": true + "noUncheckedIndexedAccess": true, + "paths": { + "@/*": ["src/*"] + } }, "include": ["next-env.d.ts", "**/*.ts", "**/*.tsx", "**/*.cjs", "**/*.mjs"], "exclude": ["node_modules"]