<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="{{ site.baseurl }}{{nav.permalink}}">
      {% if nav.top_level_section %}
        <a href="{{ site.baseurl }}{{nav.permalink}}"><h6 class="ctrl-nav-section title">{% t nav.title %}</h6></a>
      {% else %}
        <h6 class="ctrl-nav-section title">{% t 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="{{ site.baseurl }}{{nav.permalink}}#{{ doc.collection | slugify }}">{% t doc.title %}</a></li>
            {% elsif doc.url %}
              <li><a href="{{ site.baseurl }}{{nav.permalink}}{{ doc.url }}">{% t 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="{{ site.baseurl }}{{nav.permalink}}#{{ doc.id | slugify }}">{% t doc.title %}</a></li>
                {% endif %}
              {% endunless %}
            {% endfor %}
          {% endif %}
        {% endif %}
      </ul>
    </section>
  {% endfor %}
  <div class="lang-switch">
    {% for lang in site.languages %}
    <a class="{% if lang == site.lang %}active{%else%}deactive{% endif %}" href="{% if lang == site.default_lang %} {% else %}/{{ lang }}{% endif %}{{ page.url | relative_url }}"><img src="/images/i18n/{{lang}}.svg"/></a>
    {% endfor %}
  </div>
</div>
