ai-bot/app/_ui/SiderNav.tsx

44 lines
1.8 KiB
TypeScript
Raw Normal View History

"use client";
2025-01-16 10:38:01 +08:00
import Link from "next/link";
import { LinkTypeItem } from "../_lib/types";
import Logo from "./Logo";
import clsx from "clsx";
import { usePathname } from "next/navigation";
import { LinkType } from "../api/linkType/route";
export default function SiderNav({ linkList }: { linkList: LinkType[] }) {
const pathname = usePathname()
console.log(pathname);
2025-01-16 10:38:01 +08:00
return (
2025-01-16 18:30:24 +08:00
<div className="w-[220px] flex flex-col gap-y-2 fixed left-0 top-0 h-[100vh] bg-[#F9F9F9]">
2025-01-16 10:38:01 +08:00
<div>
<Logo />
</div>
<nav className="flex flex-col px-1">
{
linkList.map((item) => {
return (
item?.href ?
<Link className={clsx("cursor-pointer py-3 flex gap-x-2 items-center hover:bg-[#E0E0E0] rounded pl-3 hover:text-[#5961F9] text-[14px]",
pathname === item.href ? "text-[#5961F9]" : "text-[#515C6B]")
} href={item.href} key={item._id}>
2025-01-16 10:38:01 +08:00
{
item.iconElement
2025-01-16 10:38:01 +08:00
}
<span>{item.label}</span>
</Link> :
<div className="cursor-pointer py-3 flex gap-x-2 items-center hover:bg-[#E0E0E0] rounded pl-3 text-[#515C6B] hover:text-[#5961F9] text-[14px]" key={item._id}>
<img src={item.icon as string} className="w-[20px] h-[20px] object-cover"></img>
2025-01-16 10:38:01 +08:00
<span>{item.label}</span>
</div>
)
})
}
</nav>
2025-01-16 10:38:01 +08:00
</div >
)
}