<div id="sidebar" class="sidebar">
  
  {% assign sorted_nav = site.data.nav.toc | sort: "position" %}
  {% for nav in sorted_nav %}
    {% assign col = site.collections | where:"id", nav.collection | first %}
    <section class="pnl-main-nav-section main-nav-section" url="{{ nav.url | relative_url }}">
      {% if nav.top_level_section %}
        <a href="{{ nav.url | relative_url }}"><h6 class="ctrl-nav-section title">{{ nav.title }}</h6></a>
      {% else %}
        <h6 class="ctrl-nav-section title">{{ nav.title }}</h6>
      {% endif %}
      <ul class="cont-nav-section content">
        {% if nav.docs %}
          {% for doc in nav.docs | sort: "position" %}
            {% if doc.collection %}
              <li><a href="{{ nav.url | relative_url }}#{{ doc.collection | slugify }}">{{ doc.title }}</a></li>
            {% elsif doc.url %}
              <li><a href="{{ nav.url | relative_url }}{{ doc.url }}">{{ doc.title }}</a></li>
            {% endif %}
          {% endfor %}
        {% else %}
          {% if col %}
            {% assign sorted_docs = col.docs | sort: "position" %}
            {% for doc in sorted_docs %}
              {% unless doc.exclude_in_index %}
                {% if nav.collection == 'nodeop' %}
                  <!-- <li><a href="{{ doc.url | relative_url }}.html">{{ doc.title }}</a></li> -->
                {% else %}
                  <li><a href="{{ nav.url | relative_url }}#{{ doc.id | slugify }}">{{ doc.title }}</a></li>
                {% endif %}
              {% endunless %}
            {% endfor %}
          {% endif %}
        {% endif %}
      </ul>
    </section>
  {% endfor %}
</div>
