11ty/eleventy-navigation

Current page in breadcrumb without link?

illycz opened this issue · 1 comments

Current page in breadcrumb without link?

Hi illycz,

I had a similar spec. I created a breadcrumb component and include this is my templates. I then used an Nunjucks 'If Expression' to check if it was on the last (current) page and just render the title for that.

{% set crumbs = collections.all | eleventyNavigationBreadcrumb(eleventyNavigation.key, { includeSelf: true }) %}

{% for crumb in crumbs %}
	{% if page.url === crumb.url %} 
		{{ crumb.title }}
	{%- else -%}
    	        <a class="crumb" href="{{ crumb.url | url }}">{{ crumb.title }}</a> »
  	{%- endif -%}
{% endfor %}

(Due Credit: I got the base of my code from Mark Volkmann )