This commit is contained in:
Erik 2022-11-25 19:57:23 +02:00
parent 93b83efeb7
commit f6c7d6db44
Signed by: Navy.gif
GPG Key ID: 811EC0CD80E7E5FB

View File

@ -17,16 +17,18 @@ const SidebarMenu = ({menuItems = [], children}) => {
const elements = [];
for (const menuItem of menuItems) {
const { label, items: subItems = [], ...rest } = menuItem;
let subElements = null;
if (subItems.length) subElements = subItems.map(({ label, to, relative }) => {
if (subItems.length) subElements = subItems.map(({ label, to, relative = true }) => {
if(relative) to = `${menuItem.to}${to}`;
return <NavLink className='sidebar-menu-child-item' activeClassName='active' to={to} key={label}>{label}</NavLink>;
});
elements.push(<div key={label} className='parent-menu'>
elements.push(<div key={label} className={`parent-menu ${subElements ? 'has-children' : ''}`}>
<NavLink className='sidebar-menu-item' activeClassName='active' {...rest} key={label}>{label}</NavLink>
<div>
{subElements && <div>
{subElements}
</div>
</div>}
</div>);
}