Files
web/components/TempDesignSystem/Link/index.tsx
2024-07-15 09:47:00 +02:00

44 lines
798 B
TypeScript

"use client"
import NextLink from "next/link"
import { usePathname } from "next/navigation"
import { linkVariants } from "./variants"
import type { LinkProps } from "./link"
export default function Link({
className,
color,
href,
partialMatch = false,
textDecoration,
size,
scroll = true,
prefetch,
variant,
...props
}: LinkProps) {
const currentPageSlug = usePathname()
let isActive = currentPageSlug === href
if (partialMatch && !isActive) {
isActive = currentPageSlug === href
}
const classNames = linkVariants({
active: isActive,
className,
textDecoration,
color,
size,
variant,
})
return (
<NextLink
scroll={scroll}
prefetch={prefetch}
className={classNames}
href={href}
{...props}
/>
)
}