2021-03-30 15:47:08 -07:00
|
|
|
import { useRouter } from 'next/router'
|
|
|
|
import Link from 'next/link'
|
|
|
|
|
2021-08-16 14:34:43 -07:00
|
|
|
const MenuItem = ({ href, children, newWindow = false }) => {
|
2021-03-30 15:47:08 -07:00
|
|
|
const { asPath } = useRouter()
|
|
|
|
|
|
|
|
return (
|
2021-04-15 13:06:42 -07:00
|
|
|
<Link href={href}>
|
2021-03-30 15:47:08 -07:00
|
|
|
<a
|
2021-05-07 12:41:26 -07:00
|
|
|
className={`block text-th-fgd-1 font-bold items-center pl-3 pr-4 py-2
|
2021-05-17 22:33:04 -07:00
|
|
|
md:inline-flex md:ml-4 md:px-1 md:py-0 hover:text-th-primary hover:opacity-100
|
2021-04-12 09:49:02 -07:00
|
|
|
${
|
|
|
|
asPath === href
|
2021-05-17 22:33:04 -07:00
|
|
|
? `text-th-primary`
|
2021-04-12 09:49:02 -07:00
|
|
|
: `border-transparent hover:border-th-primary`
|
|
|
|
}
|
|
|
|
`}
|
2021-08-16 11:20:19 -07:00
|
|
|
target={newWindow ? '_blank' : ''}
|
|
|
|
rel={newWindow ? 'noopener noreferrer' : ''}
|
2021-03-30 15:47:08 -07:00
|
|
|
>
|
|
|
|
{children}
|
|
|
|
</a>
|
|
|
|
</Link>
|
|
|
|
)
|
|
|
|
}
|
|
|
|
|
|
|
|
export default MenuItem
|