_includes/components/breadcrumbs.html in just-the-docs-0.5.1 vs _includes/components/breadcrumbs.html in just-the-docs-0.5.2

- old
+ new

@@ -1,15 +1,43 @@ -{% unless page.url == "/" %} - {% if page.parent %} - <nav aria-label="Breadcrumb" class="breadcrumb-nav"> - <ol class="breadcrumb-nav-list"> - {% if page.grand_parent %} - <li class="breadcrumb-nav-list-item"><a href="{{ first_level_url }}">{{ page.grand_parent }}</a></li> - <li class="breadcrumb-nav-list-item"><a href="{{ second_level_url }}">{{ page.parent }}</a></li> - {% else %} - <li class="breadcrumb-nav-list-item"><a href="{{ first_level_url }}">{{ page.parent }}</a></li> - {% endif %} - <li class="breadcrumb-nav-list-item"><span>{{ page.title }}</span></li> - </ol> - </nav> - {% endif %} -{% endunless %} +{%- comment -%} + Include as: {%- include components/breadcrumbs.html -%} + Depends on: page, site. + Results in: HTML for the breadcrumbs component. + Overwrites: + pages_list, parent_page, grandparent_page. +{%- endcomment -%} + +{%- if page.url != "/" and page.parent -%} + + {%- assign pages_list = site[page.collection] + | default: site.html_pages + | where_exp: "item", "item.title != nil" + | where_exp: "item", "item.has_children != nil" -%} + + {%- if page.grand_parent -%} + {%- assign parent_page = pages_list + | where: "title", page.parent + | where: "parent", page.grand_parent + | first -%} + {%- assign grandparent_page = pages_list + | where: "title", page.grand_parent + | first -%} + {%- else -%} + {%- assign parent_page = pages_list + | where: "title", page.parent + | where_exp: "item", "item.parent == nil" + | first -%} + {%- endif -%} + +<nav aria-label="Breadcrumb" class="breadcrumb-nav"> + <ol class="breadcrumb-nav-list"> + {% if page.parent -%} + {%- if page.grand_parent %} + <li class="breadcrumb-nav-list-item"><a href="{{ grandparent_page.url | relative_url }}">{{ page.grand_parent }}</a></li> + {%- endif %} + <li class="breadcrumb-nav-list-item"><a href="{{ parent_page.url | relative_url }}">{{ page.parent }}</a></li> + {% endif -%} + <li class="breadcrumb-nav-list-item"><span>{{ page.title }}</span></li> + </ol> +</nav> + +{%- endif -%}