diff --git a/components/dashboard/NavBar.tsx b/components/dashboard/NavBar.tsx index c31bfdd..72b6be6 100644 --- a/components/dashboard/NavBar.tsx +++ b/components/dashboard/NavBar.tsx @@ -3,29 +3,25 @@ import { useRouter } from "next/router"; import Link from "next/link"; import { useState } from "react"; -interface NavBarProps { - initialPage: string; -} - -function NavBar(props: NavBarProps) { - const [activePage, setActivePage] = useState(props.initialPage); - const ActiveLink = (props: { - href: string; - pageName: string; - children: React.ReactNode; - }) => { - const router = useRouter(); - let styling = "text-white"; - if (activePage === props.pageName) { - styling = "text-[#a855f7]"; - } - return ( - - {props.children} - - ); - }; +const ActiveLink = (props: { + href: string; + pageName: string; + children: React.ReactNode; +}) => { + const router = useRouter(); + let styling = "text-white"; + // if first part of path equals the pageName + if (router.pathname.split("/")[1] === props.pageName) { + styling = "text-[#a855f7]"; + } + return ( + + {props.children} + + ); +}; +function NavBar() { return (
- { - setActivePage("dashboard"); - }} - > + @@ -52,9 +42,6 @@ function NavBar(props: NavBarProps) { { - setActivePage("ranking"); - }} > @@ -65,13 +52,7 @@ function NavBar(props: NavBarProps) { className="flex flex-row items-center justify-center pr-5 lg:w-full lg:flex-col lg:pr-0 lg:pb-5" variants={navStripVariants} > - { - setActivePage("wiki"); - }} - > + diff --git a/layouts/DashLayout.tsx b/layouts/DashLayout.tsx index 3ddf05e..2bbc55d 100644 --- a/layouts/DashLayout.tsx +++ b/layouts/DashLayout.tsx @@ -11,7 +11,6 @@ import NavBar from "../components/dashboard/NavBar"; interface DashLayoutProps { children: React.ReactNode; - navIcon?: string; metaTags: { title?: string; ogTitle?: string; @@ -89,7 +88,7 @@ function DashLayout(props: DashLayoutProps) { {/* dashboard nav bar */} - + {/* dashboard content */} diff --git a/pages/dashboard/index.tsx b/pages/dashboard/index.tsx index 3f8913a..0c88f80 100644 --- a/pages/dashboard/index.tsx +++ b/pages/dashboard/index.tsx @@ -80,11 +80,7 @@ const gridItemVariants: Variants = { Dashboard.getLayout = function getLayout(page: ReactElement) { const metaTags = {}; - return ( - - {page} - - ); + return {page}; }; export default Dashboard; diff --git a/pages/ranking/index.tsx b/pages/ranking/index.tsx index 766832f..ed61365 100644 --- a/pages/ranking/index.tsx +++ b/pages/ranking/index.tsx @@ -290,11 +290,7 @@ Ranking.getLayout = function getLayout(page: ReactElement) { title: "Ranking - toffee", description: "Top investors on toffee", }; - return ( - - {page} - - ); + return {page}; }; export default Ranking; diff --git a/pages/user/[username]/index.tsx b/pages/user/[username]/index.tsx index 74b5d9e..a84a7df 100644 --- a/pages/user/[username]/index.tsx +++ b/pages/user/[username]/index.tsx @@ -662,11 +662,7 @@ UserPage.getLayout = function getLayout(page: ReactElement) { "twitter:card": "summary", }, }; - return ( - - {page} - - ); + return {page}; }; export default UserPage; diff --git a/pages/wiki/[...slug]/index.tsx b/pages/wiki/[...slug]/index.tsx index 0b5dbd8..9e48730 100644 --- a/pages/wiki/[...slug]/index.tsx +++ b/pages/wiki/[...slug]/index.tsx @@ -152,11 +152,7 @@ WikiLandingPage.getLayout = function getLayout(page: React.ReactNode) { title: "Wiki - toffee", description: "Wiki for toffee", }; - return ( - - {page} - - ); + return {page}; }; export default WikiLandingPage;