2023-07-23 22:26:35 +00:00
|
|
|
import Link from "next/link";
|
|
|
|
import { ReactNode } from "react";
|
2023-08-26 02:18:11 +00:00
|
|
|
import { usePathname } from "next/navigation";
|
2023-07-23 22:26:35 +00:00
|
|
|
|
|
|
|
interface Props {
|
|
|
|
page: string;
|
|
|
|
currentPageClasses: string;
|
|
|
|
children: ReactNode;
|
|
|
|
}
|
|
|
|
|
2023-08-26 02:18:11 +00:00
|
|
|
const NavLink = ({ page, currentPageClasses, children }: Props) => {
|
2023-07-23 22:26:35 +00:00
|
|
|
const defaultClasses =
|
|
|
|
"font-bold drop-shadow hover:text-primary-100 transition-all duration-500 ";
|
|
|
|
|
2023-08-26 02:18:11 +00:00
|
|
|
const currentPage = "/" + usePathname().split("/")[1];
|
|
|
|
|
2023-07-23 22:26:35 +00:00
|
|
|
return (
|
|
|
|
<Link
|
|
|
|
className={
|
|
|
|
currentPage === page
|
|
|
|
? defaultClasses + currentPageClasses
|
|
|
|
: defaultClasses
|
|
|
|
}
|
|
|
|
href={page}
|
|
|
|
>
|
|
|
|
{children}
|
|
|
|
</Link>
|
|
|
|
);
|
|
|
|
};
|
|
|
|
|
|
|
|
export default NavLink;
|