You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

23 lines
596 B
JavaScript

import React from 'react'
import {useRouter} from 'next/router'
import Link from 'next/link'
import {Icon} from '@rmwc/icon'
import styles from './nav.module.css'
export default function NavItem({href, icon, children}) {
const {asPath: fullpath} = useRouter()
const withoutQuery = fullpath.split('?')[0]
const selected = (fullpath === href || (href !== '/admin' && fullpath.includes(href + '/')))
return (
<Link href={href}>
<a className={styles.navItem + (selected ? ' ' + styles.selected: '')}>
<Icon icon={icon} />
{children}
</a>
</Link>
)
}