|
1 | | -{% macro tree(items, currentPage) %} |
| 1 | +{% macro tree(items, currentPage, isChild = false) %} |
2 | 2 | {% for item in items %} |
| 3 | + {% set indexLabel = isChild ? '' : '%02d.'|format(loop.index) %} |
3 | 4 | {% if item.children is not empty %} |
4 | | - {{ _self.dropdown(item, currentPage, isChildActive(item.children, currentPage) or currentPage.getSlug() == item.getSlug()) }} |
| 5 | + {{ _self.dropdown(item, currentPage, isChildActive(item.children, currentPage) or currentPage.getSlug() == item.getSlug(), indexLabel) }} |
5 | 6 | {% else %} |
6 | | - {{ _self.link(item.getTitle(), item.getRoute(), currentPage.getSlug() == item.getSlug()) }} |
| 7 | + {{ _self.link(item.getTitle(), item.getRoute(), currentPage.getSlug() == item.getSlug(), indexLabel) }} |
7 | 8 | {% endif %} |
8 | 9 | {% endfor %} |
9 | 10 | {% endmacro %} |
10 | 11 |
|
11 | | -{% macro link(label, href = '#', active = false) %} |
| 12 | +{% macro link(label, href = '#', active = false, indexLabel = '') %} |
12 | 13 | <li class="{{ active ? 'uk-active' : '' }}"> |
13 | | - <a href="{{ href }}">{{ label }}</a> |
| 14 | + <a href="{{ href }}">{{ _self.index(indexLabel) }}{{ label }}</a> |
14 | 15 | </li> |
15 | 16 | {% endmacro %} |
16 | 17 |
|
17 | | -{% macro dropdown(item, currentPage, open = false) %} |
| 18 | +{% macro dropdown(item, currentPage, open = false, indexLabel = '') %} |
18 | 19 | <li class="uk-parent {{ open ? 'uk-open' : '' }} {{ currentPage.getSlug() == item.getSlug() ? 'uk-active' : '' }}"> |
19 | 20 | <a href="{{ item.getRoute() }}"> |
20 | | - {{ item.getTitle() }} |
| 21 | + {{ _self.index(indexLabel) }}{{ item.getTitle() }} |
21 | 22 | </a> |
22 | 23 | <ul class="uk-nav-sub"> |
23 | | - {{ _self.tree(item.children, currentPage) }} |
| 24 | + {{ _self.tree(item.children, currentPage, true) }} |
24 | 25 | </ul> |
25 | 26 | </li> |
26 | 27 | {% endmacro %} |
27 | 28 |
|
| 29 | +{% macro index(indexLabel = '') %} |
| 30 | + {% if indexLabel %}<span class="sidebar-index" aria-hidden="true">{{ indexLabel }}</span> {% endif %} |
| 31 | +{% endmacro %} |
| 32 | + |
28 | 33 | {% macro label(label) %} |
29 | 34 | <li class="uk-nav-header">{{ label }}</li> |
30 | 35 | {% endmacro %} |
0 commit comments