{% if page.toc %}

  {%- set toc_ns = namespace(top_level_headings=0) %}
  {% for toc_item in page.toc %}
    {%- set toc_ns.top_level_headings = toc_ns.top_level_headings + 1 %}
  {% endfor %}

  {%- set toclevel = 0 %}
  <ul class="{% if nav_item.active%}current{%endif%} subnav">
    {% for toc_item in page.toc %}
      {% include "toc-item.html" %}
    {% endfor %}
  </ul>
{% endif %}
