<nav id="side-nav" class="side-nav is-condensed">
  <header>{% include "searchbox.html" %}</header>

  <div id="side-nav-menu" class="side-nav-menu">
    {% for nav_item in nav %}
      {% if nav_item.title != "hidden" %}
        {% if nav_item.children %}
          <h3 class="side-nav-section-header">
            {{ nav_item.title }}
          </h3>

          {% if nav_item.title != "hidden" %}
            {% for nav_item in nav_item.children %}
              <ul class="side-nav-buttons">
                <li>
                  <a class="{% if nav_item.active%}is-active{%endif%}" href="{{ nav_item.url }}">{{ nav_item.title }}</a>
                </li>
              </ul>
            {% endfor %}
          {% endif %}
        {% else %}
          <ul class="side-nav-buttons">
            <li>
              <a class="{% if nav_item.active%}is-active{%endif%}" href="{{ nav_item.url }}">{{ nav_item.title }}</a>
            </li>
          </ul>

          {% if nav_item == page %}
            <ul class="side-nav-secondary-buttons">
              {% for toc_item in page.toc %}
                <li class="{% if toc_item.active%}is-active{%endif%}"><a href="{{ toc_item.url }}">{{ toc_item.title }}</a></li>
                {% for toc_item in toc_item.children %}
                <li><a href="{{ toc_item.url }}">{{ toc_item.title }}</a></li>
                {% endfor %}
              {% endfor %}
            </ul>
          {% endif %}
        {% endif %}
      {% endif %}
    {% endfor %}
  </div>
</nav>