subman-nextjs/src/app/ui/navLinks.tsx

33 lines
940 B
TypeScript
Raw Normal View History

2024-06-20 18:02:25 +00:00
"use client"
import Link from "next/link";
import { usePathname } from "next/navigation";
import { ComponentProps } from "react";
import clsx from "clsx";
function NavLink(props: ComponentProps<"div"> & { href: string }) {
return (
<Link href={props.href}><h1 className={props.className}>{props.children}</h1></Link>
)
}
export default function Navlinks(props: ComponentProps<"div">) {
const pathname = usePathname()
const links = [
{ link: "/story", label: "STORIES" },
{ link: "/publication", label: "PUBLICATIONS" },
{ link: "/submission", label: "SUBMISSIONS" },
]
return (
2024-06-22 16:12:55 +00:00
<div className={props.className}>
2024-06-20 18:02:25 +00:00
{links.map(e => (<NavLink key={e.link} href={e.link}
2024-06-22 16:12:55 +00:00
className={clsx("text-xl font-black my-2 w-full pl-2 antialiased",
2024-06-20 18:02:25 +00:00
{
2024-06-22 16:12:55 +00:00
"text-primary-foreground bg-primary": pathname === e.link
2024-06-20 18:02:25 +00:00
}
)}
>{e.label}</NavLink >))
}
2024-06-22 16:12:55 +00:00
</div>
2024-06-20 18:02:25 +00:00
)
}