
{#| Find the first childs url |#}

{%- set input_path = '' %}
{%- if nav_item.children %}
  {%- if nav_item.children[0].input_path %}
    {%- set urlList = nav_item.children[0].input_path.split('.') %}
  {%- else %}
    {%- if nav_item.children[0].children[0].input_path %}
      {%- set urlList = nav_item.children[0].children[0].input_path.split('.') %}
    {%- endif %}
  {%- endif %}
  {%- set fileName = urlList.pop() %}
  {%- set input_path = '.'.join(urlList) %}
{%- endif %}



{%- if input_path == ''  %}
  <a class="{% if nav_item.active%}current{%endif%}" href="{{ nav_item.url }}">{{ nav_item.title }}</a>
{%- else %}
  <a class="{% if nav_item.active%}current{%endif%}" href="/{{ input_path }}">{{ nav_item.title }}</a>
{%- endif %}

{%- if nav_item.active and (nav_item == page or nav_item.children) %}
  <ul class="subnav">
    {%- if nav_item == page %}
      {% include 'toc.html' %}
    {%- endif %}
    {%- if nav_item.children %}
      {%- set navlevel = navlevel + 1%}
      {%- for nav_item in nav_item.children %}
        <li class="toctree-l{{ navlevel }}{% if nav_item.active%} current{%endif%}">
          {% include 'nav.html' %}
        </li>
      {%- endfor %}
      {%- set navlevel = navlevel - 1%}
    {%- endif %}
  </ul>
{%- endif %}
