-
Notifications
You must be signed in to change notification settings - Fork 2
/
breadcrumbs.html
38 lines (34 loc) · 1.28 KB
/
breadcrumbs.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
<!-- Twitter Bootstrap 3 style -->
<ol class="breadcrumb">
{% for category in page.categories %}
{% assign current_index = forloop.index %}
{% assign page_cats = page.categories | join: '/' %}
{% for element in page.categories %}
{% if forloop.index > current_index %}
{% capture page_cats %}{{ page_cats | replace: element, '' }}{% endcapture %}
{% endif %}
{% endfor %}
{% capture category_with_slash %}{{ page_cats | replace: '//', '/' }}/index.html{% endcapture %}
{% capture category_with_slash %}{{ category_with_slash | replace: '//', '/' }}{% endcapture %}
<!-- Category path: {{ category_with_slash }} -->
{% assign category_page_found = false %}
<li>
{% for category_page in site.pages %}
{% if category_page.url contains category_with_slash %}
{% if category_page.title and category_page.title != '' %}
<a href="{{ category_page.url | replace: 'index.html', '' }}">
{{ category_page.title }}
</a>
{% assign category_page_found = true %}
{% endif %}
{% endif %}
{% endfor %}
{% unless category_page_found %}
{{ category | capitalize | replace: '-', ' ' }}
{% endunless %}
</li>
{% endfor %}
<li class="active">
{{ page.title | truncatewords: 10 }}
</li>
</ol>