@using BlazorPathHelper
@foreach(var menuItem in MenuItems)
{
<!-- Use menuItem.Key for defining the key attribute -->
<div @key=menuItem.Key class="nav-item ps-3 py-1">
<!-- menuItem.Path represents the URL path of the menu item -->
<!-- NavLinkMatch.All applies only to the homepage, others use Prefix -->
<NavLink class="nav-link" href="@menuItem.Path"
Match="@(menuItem.IsHome ? NavLinkMatch.All : NavLinkMatch.Prefix)">
<!-- Icons and menu names are passed as strings -->
<span class="me-2 fs-5 @menuItem.Icon" aria-hidden="true"></span>
@menuItem.Name
</NavLink>
<!-- Recursively call to display child elements -->
<nav class="flex-column">
<NavMenuItem MenuItems="menuItem.Children"/>
</nav>
</div>
}
@code {
// Accepts an array of menu items
[Parameter, EditorRequired]
public BlazorPathMenuItem[] MenuItems { get; set; } = [];
}