{% macro nav_link(label, target) -%}
    <li class="nav-item">
        <a class="nav-link nav-internal" href="{{ target if target.startswith('http') else pathto(target) }}">{{ label }}</a>
    </li>
{%- endmacro %}


<nav class="navbar-nav">
    <p class="sidebar-header-items__title"
       role="heading"
       aria-level="1"
       aria-label="{{ _('Site Navigation') }}">
        {{ _("Site Navigation") }}
    </p>
    <ul id="navbar-main-elements" class="navbar-nav">
        {% for label, item in navbar_items | items %}
            {% if item is string %}
                {{ nav_link(label, item) }}
            {% else %}
                <div class="nav-item dropdown">
                    <button class="btn dropdown-toggle nav-item" type="button"
                            data-toggle="dropdown">{{ label }}</button>
                    <ul class="dropdown-menu">
                        {% for child_label, child_item in item | items %}
                            {{ nav_link(child_label, child_item) }}
                        {% endfor %}
                    </ul>
                </div>
            {% endif %}
        {% endfor %}
    </ul>
</nav>
