|
24 | 24 | --> |
25 | 25 |
|
26 | 26 | <!-- Render navigation link content --> |
27 | | -{% macro render_content(nav_item) %} |
| 27 | +{% macro render_content(nav_item, ref) %} |
| 28 | + {% set ref = ref or nav_item %} |
28 | 29 | <span class="md-ellipsis"> |
29 | | - {{ nav_item.title }} |
| 30 | + {{ ref.title or nav_item.title }} |
30 | 31 | </span> |
31 | 32 | {% endmacro %} |
32 | 33 |
|
|
36 | 37 |
|
37 | 38 | <!-- Navigation item with nested items --> |
38 | 39 | {% if nav_item.children %} |
39 | | - {% set first = nav_item.children | first %} |
| 40 | + |
| 41 | + <!-- Determine all nested items that are index pages --> |
| 42 | + {% set _ = namespace(index = none) %} |
| 43 | + {% if "navigation.indexes" in features %} |
| 44 | + {% for item in nav_item.children %} |
| 45 | + {% if item.is_index and _.index is none %} |
| 46 | + {% set _.index = item %} |
| 47 | + {% endif %} |
| 48 | + {% endfor %} |
| 49 | + {% endif %} |
| 50 | + {% set index = _.index %} |
| 51 | + |
| 52 | + <!-- Use index page as entry point if present, otherwise first child --> |
| 53 | + {% set first = index or nav_item.children | first %} |
40 | 54 |
|
41 | 55 | <!-- Recurse, if the first item has further nested items --> |
42 | 56 | {% if first.children %} |
|
46 | 60 | {% else %} |
47 | 61 | <li class="md-path__item"> |
48 | 62 | <a href="{{ first.url | url }}" class="md-path__link"> |
49 | | - {{ render_content(ref) }} |
| 63 | + {{ render_content(first, ref) }} |
50 | 64 | </a> |
51 | 65 | </li> |
52 | 66 | {% endif %} |
|
55 | 69 | {% else %} |
56 | 70 | <li class="md-path__item"> |
57 | 71 | <a href="{{ nav_item.url | url }}" class="md-path__link"> |
58 | | - {{ render_content(ref) }} |
| 72 | + {{ render_content(first, ref) }} |
59 | 73 | </a> |
60 | 74 | </li> |
61 | 75 | {% endif %} |
|
0 commit comments