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
601 B
JavaScript
23 lines
601 B
JavaScript
5 years ago
|
import React from 'react'
|
||
|
import {useRouter} from 'next/router'
|
||
|
import Link from 'next/link'
|
||
|
import {Icon} from '@rmwc/icon'
|
||
|
|
||
|
import styles from './adminNav.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>
|
||
|
)
|
||
|
}
|