{# Recursive: nav depth is unbounded, so a section includes this same template for each of its children. The inner `for` rebinds `nav_item` in loop scope, which is what makes the recursion work (same trick as mkdocs-basic-theme). #} {%- if nav_item.children %} {# `data-primer-nav-open` is the section's expanded state, and the only one. The stylesheet hides the children of a section without it once the document is known to be scriptable, and js/nav-sections.js moves the attribute when the reader works the toggle. With no JavaScript nothing is hidden and every section stays open, which is what this nav did before. #}
{# A section normally has no url. mkdocs-section-index gives it one by folding the section's index page into the section itself, and then the label is the only route to that page — rendering it as inert text drops the page out of the nav entirely. #} {# `active` is true for a section anywhere above the current page, which is the only signal the tree has for "you are in here" — the leaf item's aria-current says nothing about its ancestors. #} {%- set section_label_class = 'primer-nav-section-label' ~ (' primer-nav-section-label-active' if nav_item.active else '') %} {# The row the toggle button is appended to; on its own it lays out as the label did. #}
{%- if nav_item.url %} {%- else %} {%- endif %}
{%- for nav_item in nav_item.children %} {% include "partials/nav-item.html" %} {%- endfor %}
{%- else %} {{ nav_item.title }} {%- endif %}