<a class="{% if not nav_item.is_link %}reference internal{% endif %}{% if nav_item.active%} current{%endif%}" href="{% if not nav_item.is_section %}{{ nav_item.url|url }}{% else %}#{% endif %}">{{ nav_item.title }}</a>
{%- set navlevel = navlevel + 1 %}
{%- if navlevel <= config.theme.navigation_depth
    and ((nav_item.is_page and nav_item.toc.items
    and (not config.theme.titles_only
    and (nav_item == page or not config.theme.collapse_navigation)))
    or (nav_item.is_section and nav_item.children)) %}
    <ul{% if nav_item.active %} class="current"{% endif %}>
        {%- if nav_item.is_page %}
            {#- Skip first level of toc which is page title. #}
            {%- set toc_item = nav_item.toc.items[0] %}
            {%- include 'toc.html' %}
        {%- elif nav_item.is_section %}
            {%- for nav_item in nav_item.children %}
                <li class="toctree-l{{ navlevel }}{% if nav_item.active%} current{%endif%}">
                    {%- include 'nav.html' %}
                </li>
            {%- endfor %}
        {%- endif %}
    </ul>
{%- endif %}
{%- set navlevel = navlevel - 1 %}
