-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMenu.jsx
37 lines (30 loc) · 974 Bytes
/
Menu.jsx
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
import React from "react";
import Link from "next/link";
import { useRouter } from "next/router";
import styles from "../styles/components/Menu.module.css";
function Menu({ language, menuItems }) {
const route = useRouter();
const [, menuActivated] = route.pathname.split("/");
return (
<nav className={styles.menu}>
{menuItems.map((menuItem, index) => {
const linkClasses = [styles.menuItem];
if (!menuItem.visible) return null;
if (menuActivated === menuItem.rootPath) {
linkClasses.push(styles.menuActive);
}
return (
<Link key={`menu-${index}`} href={menuItem.path}>
<a className={linkClasses.join(" ")}>
<menuItem.Icon className={styles.menuIcon} />
<span className={styles.menuLabel}>
{language[menuItem.label]}
</span>
</a>
</Link>
);
})}
</nav>
);
}
export default Menu;