nav-item.html (3401B)
1 {#- 2 This file was automatically generated - do not edit 3 -#} 4 {% macro render(nav_item, path, level) %} 5 {% set class = "md-nav__item" %} 6 {% if nav_item.active %} 7 {% set class = class ~ " md-nav__item--active" %} 8 {% endif %} 9 {% if nav_item.children %} 10 {% if "navigation.sections" in features and level == 1 + ( 11 "navigation.tabs" in features 12 ) %} 13 {% set class = class ~ " md-nav__item--section" %} 14 {% endif %} 15 <li class="{{ class }} md-nav__item--nested"> 16 {% set checked = "checked" if nav_item.active %} 17 {% if "navigation.expand" in features and not checked %} 18 <input class="md-nav__toggle md-toggle md-toggle--indeterminate" data-md-toggle="{{ path }}" type="checkbox" id="{{ path }}" checked> 19 {% else %} 20 <input class="md-nav__toggle md-toggle" data-md-toggle="{{ path }}" type="checkbox" id="{{ path }}" {{ checked }}> 21 {% endif %} 22 {% set indexes = [] %} 23 {% if "navigation.indexes" in features %} 24 {% for nav_item in nav_item.children %} 25 {% if nav_item.is_index and not index is defined %} 26 {% set _ = indexes.append(nav_item) %} 27 {% endif %} 28 {% endfor %} 29 {% endif %} 30 {% if not indexes %} 31 <label class="md-nav__link" for="{{ path }}"> 32 {{ nav_item.title }} 33 <span class="md-nav__icon md-icon"></span> 34 </label> 35 {% else %} 36 {% set index = indexes | first %} 37 {% set class = "md-nav__link--active" if index == page %} 38 <div class="md-nav__link md-nav__link--index {{ class }}"> 39 <a href="{{ index.url | url }}">{{ nav_item.title }}</a> 40 {% if nav_item.children | length > 1 %} 41 <label for="{{ path }}"> 42 <span class="md-nav__icon md-icon"></span> 43 </label> 44 {% endif %} 45 </div> 46 {% endif %} 47 <nav class="md-nav" aria-label="{{ nav_item.title }}" data-md-level="{{ level }}"> 48 <label class="md-nav__title" for="{{ path }}"> 49 <span class="md-nav__icon md-icon"></span> 50 {{ nav_item.title }} 51 </label> 52 <ul class="md-nav__list" data-md-scrollfix> 53 {% for nav_item in nav_item.children %} 54 {% if not indexes or nav_item != indexes | first %} 55 {{ render(nav_item, path ~ "_" ~ loop.index, level + 1) }} 56 {% endif %} 57 {% endfor %} 58 </ul> 59 </nav> 60 </li> 61 {% elif nav_item == page %} 62 <li class="{{ class }}"> 63 {% set toc = page.toc %} 64 <input class="md-nav__toggle md-toggle" data-md-toggle="toc" type="checkbox" id="__toc"> 65 {% set first = toc | first %} 66 {% if first and first.level == 1 %} 67 {% set toc = first.children %} 68 {% endif %} 69 {% if toc %} 70 <label class="md-nav__link md-nav__link--active" for="__toc"> 71 {{ nav_item.title }} 72 <span class="md-nav__icon md-icon"></span> 73 </label> 74 {% endif %} 75 <a href="{{ nav_item.url | url }}" class="md-nav__link md-nav__link--active"> 76 {{ nav_item.title }} 77 </a> 78 {% if toc %} 79 {% include "partials/toc.html" %} 80 {% endif %} 81 </li> 82 {% else %} 83 <li class="{{ class }}"> 84 <a href="{{ nav_item.url | url }}" class="md-nav__link"> 85 {{ nav_item.title }} 86 </a> 87 </li> 88 {% endif %} 89 {% endmacro %} 90 {{ render(nav_item, path, level) }}