|
34 | 34 | {% endif %} |
35 | 35 | {% endfor %} |
36 | 36 | {% endif %} |
| 37 | + {% set visible_children = [] %} |
| 38 | + {% for nav_item in nav_item.children %} |
| 39 | + {% if not indexes or nav_item != indexes | first %} |
| 40 | + {% set _ = visible_children.append({ 'idx': loop.index, 'node': nav_item }) %} |
| 41 | + {% endif %} |
| 42 | + {% endfor %} |
37 | 43 | {% if not indexes %} |
38 | 44 | <label class="md-nav__link" for="{{ path }}" id="{{ path }}_label" tabindex="0"> |
39 | 45 | {{ render_title_with_icon(nav_item.title, "twemoji nav-title") | safe }} |
|
54 | 60 | {% endif %} |
55 | 61 | </div> |
56 | 62 | {% endif %} |
57 | | - <nav class="md-nav" data-md-level="{{ level }}" aria-labelledby="{{ path }}_label" aria-expanded="{{ nav_item.active | tojson }}"> |
58 | | - <label class="md-nav__title" for="{{ path }}"> |
59 | | - <span class="md-nav__icon md-icon"></span> |
60 | | - {{nav_item.title}} |
61 | | - </label> |
62 | | - <div class="nav-wrapper"> |
63 | | - {% if page %} |
64 | | - {% if indexes[0] %} |
65 | | - <ul class="md-nav__list {{ indexes[0].url.replace('/', '-') }}" data-md-scrollfix> |
66 | | - {% endif %} |
67 | | - {% endif %} |
68 | | - {% for nav_item in nav_item.children %} |
69 | | - {% if not indexes or nav_item != indexes | first %} |
70 | | - {{ render(nav_item, path ~ "_" ~ loop.index, level + 1) }} |
71 | | - {% endif %} |
72 | | - {% endfor %} |
73 | | - </ul> |
74 | | - </div> |
75 | | - </nav> |
| 63 | + |
| 64 | + {% if visible_children | length > 0 %} |
| 65 | + <nav class="md-nav" |
| 66 | + data-md-level="{{ level }}" |
| 67 | + aria-labelledby="{{ path }}_label" |
| 68 | + aria-expanded="{{ nav_item.active | tojson }}"> |
| 69 | + |
| 70 | + <label class="md-nav__title" for="{{ path }}"> |
| 71 | + <span class="md-nav__icon md-icon"></span> |
| 72 | + {{ nav_item.title }} |
| 73 | + </label> |
| 74 | + |
| 75 | + {% set indexes_class = indexes[0].url.replace('/', '-') if indexes and indexes[0] else '' %} |
| 76 | + <div class="nav-wrapper"> |
| 77 | + <ul class="md-nav__list {{ indexes_class }}" data-md-scrollfix> |
| 78 | + {% for it in visible_children %} |
| 79 | + {{ render(it.node, path ~ "_" ~ it.idx, level + 1) }} |
| 80 | + {% endfor %} |
| 81 | + </ul> |
| 82 | + </div> |
| 83 | + </nav> |
| 84 | + {% endif %} |
76 | 85 | </li> |
77 | 86 | {% elif nav_item == page %} |
78 | 87 | <li class="{{ class }}"> |
|
0 commit comments