mirror of
https://github.com/jambonz/next-static-site.git
synced 2026-10-30 15:24:32 +00:00
Fix bug with regex matching active navi link for mobile and style mobile active navi link
This commit is contained in:
1 parent
6a54e2088c
commit
d269a63d48
2 files changed
+20
-6
No files matched your search
+4
-2
@@ -9,10 +9,12 @@ import { Button, Icon, useMobileMedia } from './jambonz-ui';
|
||||
|
||||
function NaviItem({obj}) {
|
||||
const router = useRouter();
|
||||
const regex = new RegExp(`^${obj.link}`);
|
||||
const rSlash = /^\/|\/$/g;
|
||||
const cleanLink = obj.link.replace(rSlash, '');
|
||||
const cleanPath = router.asPath.replace(rSlash, '');
|
||||
const classes = {
|
||||
navi__link: true,
|
||||
active: regex.test(router.asPath),
|
||||
active: cleanLink === cleanPath,
|
||||
};
|
||||
|
||||
return (
|
||||
|
||||
Reference in new issue
Block a user