import React from "react"; import Link from "next/link"; import { useRouter } from "next/router"; import { Image } from "./Image"; import styles from "./Navbar.module.css"; interface NavLink { name: string; route: string; submenu?: { name: string; route: string; }[]; } const menu: NavLink[] = [ { name: "Home", route: "/", }, { name: "About", route: "/about", submenu: [ { name: "About Us", route: "/about", }, { name: "Meet the Team", route: "/about/team", }, { name: "Constitution", route: "/about/constitution", }, { name: "Code of Conduct", route: "/about/code-of-conduct", }, { name: "Our Supporters", route: "/about/our-supporters", }, ], }, { name: "Get Involved", route: "/get-involved", }, { name: "Events", route: "/events", }, { name: "Resources", route: "/resources/services", submenu: [ { name: "Services", route: "/resources/services", }, { name: "Tech Talks", route: "/resources/tech-talks", }, { name: "CS Club Wiki", route: "https://wiki.csclub.uwaterloo.ca/", }, ], }, ]; function NavItem(props: NavLink) { const router = useRouter(); const externalLink = props.route.includes("http://") || props.route.includes("https://"); return ( <> {externalLink ? ( { if (document.activeElement instanceof HTMLElement) { document.activeElement.blur(); } }} > {props.name} ) : ( 0 && router.pathname.startsWith(props.route)) ? styles.currentPage : "" } onClick={() => { if (document.activeElement instanceof HTMLElement) { document.activeElement.blur(); } }} > {props.name} )} {(props.submenu?.length ?? 0) > 0 ? ( ) : null} ); } export function Navbar() { return ( ); }