From ec3f4a51dc809833229ff361d65e91ebee287947 Mon Sep 17 00:00:00 2001
From: libertyoms
Date: Sun, 18 May 2025 09:39:57 +0200
Subject: [PATCH] shwo active page
---
components/Footer.tsx | 52 +++--
components/Header.tsx | 11 +-
components/HeaderClient.tsx | 393 ++++++++++++++++++++++--------------
3 files changed, 282 insertions(+), 174 deletions(-)
diff --git a/components/Footer.tsx b/components/Footer.tsx
index 393ce5b..fe22f5f 100644
--- a/components/Footer.tsx
+++ b/components/Footer.tsx
@@ -157,20 +157,44 @@ const Footer = () => {
diff --git a/components/Header.tsx b/components/Header.tsx
index 636715a..9e4eae8 100644
--- a/components/Header.tsx
+++ b/components/Header.tsx
@@ -1,22 +1,13 @@
// components/Header.tsx (Server Component)
import React from "react";
-import { auth } from "@/auth"; // Only need auth (for session) from here now
import HeaderClient from "./HeaderClient";
-import { handleSignInAction, handleSignOutAction } from "@/actions/auth-action";
const Header = async () => {
// Fetch session data on the server
- const session = await auth();
// Pass the session data and YOUR Server Actions as props
- return (
-
- );
+ return
;
};
export default Header;
diff --git a/components/HeaderClient.tsx b/components/HeaderClient.tsx
index 57e49ee..a7e905f 100644
--- a/components/HeaderClient.tsx
+++ b/components/HeaderClient.tsx
@@ -4,6 +4,7 @@
import React, { useState } from "react";
import Link from "next/link";
import Image from "next/image";
+import { usePathname } from "next/navigation"; // Import usePathname
import {
FiChevronDown,
FiClipboard,
@@ -54,6 +55,20 @@ const HeaderClient = () => {
const handleJoinUsMouseEnter = () => setJoinUsDropdownOpen(true);
const handleJoinUsMouseLeave = () => setJoinUsDropdownOpen(false);
+ const pathname = usePathname(); // Get current path
+
+ // Helper function to check if a path is active (exact match for simple links, startsWith for base paths)
+ const isActive = (href: string, exact = false) => {
+ if (exact) {
+ return pathname === href;
+ }
+ // Handle root path specifically
+ if (href === "/") {
+ return pathname === "/";
+ }
+ return pathname.startsWith(href);
+ };
+
const megaMenuTriggerClasses = `
relative inline-flex items-center text-sm font-medium text-primary-foreground
hover:opacity-90 transition-opacity duration-150 ease-in-out pb-1
@@ -94,25 +109,41 @@ const HeaderClient = () => {