Portfolio-v3/components/navlink.js
Robert S 79cc0cb8d1
Layout function o.O
Cleaned up the code and that's about it.
2021-12-10 23:09:37 +01:00

18 lines
No EOL
479 B
JavaScript

import React from 'react'
import Link from 'next/link'
import { useRouter } from 'next/router'
const NavLink = ({ href, children }) => {
const router = useRouter()
let className = children.props.className || ''
if (router.pathname === href) {
className = `${className} text-white`
} else {
className = `${className} text-gray-400`
}
return <Link href={href}>{React.cloneElement(children, { className })}</Link>
}
export default NavLink