Skip to content
Snippets Groups Projects
nav.html 1.33 KiB
Newer Older
Lukáš Krupčík's avatar
Lukáš Krupčík committed
<!-- Render sections -->
Lukáš Krupčík's avatar
Lukáš Krupčík committed
{% if nav_item.children %}
  <li>
    <span class="section">{{ nav_item.title }}</span>
    <ul>
Lukáš Krupčík's avatar
Lukáš Krupčík committed

      <!-- Render pages of section -->
Lukáš Krupčík's avatar
Lukáš Krupčík committed
      {% for nav_item in nav_item.children %}
        {% include "nav.html" %}
      {% endfor %}
    </ul>
  </li>
Lukáš Krupčík's avatar
Lukáš Krupčík committed

<!-- Render page link -->
Lukáš Krupčík's avatar
Lukáš Krupčík committed
{% else %}
  <li>
Lukáš Krupčík's avatar
Lukáš Krupčík committed
    <a class="{% if nav_item.active %}current{% endif %}"
      title="{{ nav_item.title }}" href="{{ nav_item.url }}" >
Lukáš Krupčík's avatar
Lukáš Krupčík committed
      {{ nav_item.title }}
    </a>
Lukáš Krupčík's avatar
Lukáš Krupčík committed

    <!-- Expand active pages -->
Lukáš Krupčík's avatar
Lukáš Krupčík committed
    {% if nav_item == current_page %}
Lukáš Krupčík's avatar
Lukáš Krupčík committed

      <!--
        The top-level anchor must be skipped if the article contains a h1
        headline, since it would be redundant to the link to the current page
        that is located just above the anchor. Therefore we directly continue
        with the children of the anchor.
      -->
Lukáš Krupčík's avatar
Lukáš Krupčík committed
      {% if h1 %}
        {% set toc = (toc | first).children %}
      {% endif %}
Lukáš Krupčík's avatar
Lukáš Krupčík committed

      <!-- Render anchors of active page -->
Lukáš Krupčík's avatar
Lukáš Krupčík committed
      {% if toc and (toc | first) %}
        <ul>
          {% for toc_item in toc %}
Lukáš Krupčík's avatar
Lukáš Krupčík committed

            <!-- Render anchor -->
Lukáš Krupčík's avatar
Lukáš Krupčík committed
            <li class="anchor">
              <a title="{{ toc_item.title }}" href="{{ toc_item.url }}">
                {{ toc_item.title }}
              </a>
            </li>
          {% endfor %}
        </ul>
      {% endif %}
    {% endif %}
  </li>
{% endif %}