post-breadcrumb.html 1016 Bytes
Newer Older
Martin Bieder's avatar
Martin Bieder committed
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
{% capture url_parts %}
    {{ page.url | remove: "/index.html" | replace:'/'," " }}
{% endcapture %}

{% capture num_parts %}
    {{ url_parts | number_of_words | minus: 1 }}
{% endcapture %}

{% assign previous="" %}

<ol class="breadcrumb">
    {% if num_parts == "0" or num_parts == "-1" %}
        <li>
            <a href="{{ site.baseurl }}/">Home</a>
        </li>
    {% else %}

        <li>
            <a href="{{ site.baseurl }}/">Home</a>
        </li>

        {% for unused in page.content limit:num_parts %}
            {% capture first_word %}{{ url_parts | truncatewords:1 | remove:"..."}}{% endcapture %}
            {% capture previous %}{{ previous }}/{{ first_word }}{% endcapture %}

            <li>
                <a href="{{ site.baseurl }}{{previous}}">{{ first_word | capitalize }}</a>
            </li>

            {% capture url_parts %}{{ url_parts | remove_first:first_word }}{% endcapture %}
        {% endfor %}
    {% endif %}
    <li class="active">{{ page.title }}</li>
</ol>