From 5ad6ce7894acab1da50c7ee3804f993d1ac46b31 Mon Sep 17 00:00:00 2001 From: Nico Haider Date: Fri, 17 Apr 2026 17:48:17 +0200 Subject: [PATCH] style(nav): mark current link --- app/[locale]/navbar.tsx | 27 ++++++++++++++++++++++----- 1 file changed, 22 insertions(+), 5 deletions(-) diff --git a/app/[locale]/navbar.tsx b/app/[locale]/navbar.tsx index e57d1b4..7ae2f27 100644 --- a/app/[locale]/navbar.tsx +++ b/app/[locale]/navbar.tsx @@ -1,13 +1,13 @@ "use client" import { Fragment, useEffect, useState } from "react" -import Link from "next/link" import { cn } from "@/lib/utils" import { ThemeSwitch } from "../../components/custom/theme-switch" import { useTranslations } from "next-intl" import { LocaleSwitch } from "../../components/custom/locale-switch" import { Button } from "@/components/ui/button" import { Menu, X } from "lucide-react" +import { Link, usePathname } from "@/i18n/navigation" import { DropdownMenu, DropdownMenuContent, @@ -19,6 +19,7 @@ import { export default function Navbar() { const [scrolled, setScrolled] = useState(false); const [mobileMenuOpen, setMobileMenuOpen] = useState(false); + const pathname = usePathname() const t = useTranslations('pages'); useEffect(() => { @@ -47,6 +48,12 @@ export default function Navbar() { { href: "/projects", label: t("projects") }, ]; + const isActiveHref = (href: string) => { + if (!pathname) return false + if (href === "/") return pathname === "/" + return pathname === href || pathname.startsWith(`${href}/`) + } + return (
@@ -63,12 +70,19 @@ export default function Navbar() { : "border-foreground/0" )} > -

bH

+

bH