Files
web/components/TempDesignSystem/Link/index.tsx
Michael Zetterberg 14e93eba7c chore: lint fix
2024-04-23 14:43:17 +02:00

30 lines
639 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,
href,
partialMatch = false,
size,
variant,
...props
}: LinkProps) {
const currentPageSlug = usePathname()
let isActive = currentPageSlug === href
if (partialMatch && !isActive) {
isActive = currentPageSlug.startsWith(href)
}
const classNames = linkVariants({
active: isActive,
className,
size,
variant,
})
return <NextLink className={classNames} href={href} {...props} />
}