Skip to content

Commit 25c9621

Browse files
fix(TopNav): improve navigation logic by adding pathname handling for conditional rendering
1 parent 1ac19ae commit 25c9621

1 file changed

Lines changed: 6 additions & 2 deletions

File tree

src/components/navbar/TopNav.tsx

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ import { GiSelfLove } from "react-icons/gi";
1212
import NavLink from "./NavLink";
1313
import UserMenu from "./UserMenu";
1414
import FiltersWrapper from "./FiltersWrapper";
15+
import { usePathname } from "next/navigation";
1516

1617
type Props = {
1718
userInfo: {
@@ -27,6 +28,8 @@ export default function TopNav({
2728
isLoggedIn,
2829
isAdmin,
2930
}: Props) {
31+
const pathname = usePathname();
32+
const isHomePage = pathname === "/";
3033

3134
const memberLinks = [
3235
{ href: "/members", label: "Matches" },
@@ -90,7 +93,7 @@ export default function TopNav({
9093
<div className="ml-auto">
9194
<UserMenu userInfo={userInfo} />
9295
</div>
93-
) : (
96+
) : !isHomePage ? (
9497
<div className="ml-auto flex items-center gap-3">
9598
<Button
9699
as={Link}
@@ -109,7 +112,8 @@ export default function TopNav({
109112
Register
110113
</Button>
111114
</div>
112-
)}
115+
) : null
116+
}
113117
</NavbarContent>
114118
</Navbar>
115119
<FiltersWrapper />

0 commit comments

Comments
 (0)