mirror of
https://github.com/BradNut/weddingsite
synced 2025-09-08 17:40:36 +00:00
20 lines
465 B
JavaScript
20 lines
465 B
JavaScript
|
|
import React from 'react';
|
||
|
|
import Link from 'next/link';
|
||
|
|
import { useRouter } from 'next/router';
|
||
|
|
|
||
|
|
export const NavLink = ({ children, href }) => {
|
||
|
|
const child = React.Children.only(children);
|
||
|
|
const router = useRouter();
|
||
|
|
|
||
|
|
return (
|
||
|
|
<Link href={href}>
|
||
|
|
{React.cloneElement(child, {
|
||
|
|
'aria-current':
|
||
|
|
router.pathname === href || router.pathname.includes(`${href}/`)
|
||
|
|
? 'page'
|
||
|
|
: null,
|
||
|
|
})}
|
||
|
|
</Link>
|
||
|
|
);
|
||
|
|
};
|