Is it possible to add an active
class to the current (last) item in breadcrumbs? For example, if home>news
or home>capital>news
, then news
gets an active class? Below is my code.
{{- if not .IsHome -}}
<p class="breadcrumbs">
<a href="/">Home</a> <span class="pointer">» </span>
{{- template "breadcrumb" dict "currentPage" .Page "id" .File.UniqueID -}}
</p>
{{- end -}}
{{- define "breadcrumb" -}}
{{- $page := .currentPage -}}
{{- if $page.Parent -}}
{{- if ne $page.Parent .IsHome -}}
{{- template "breadcrumb" dict "currentPage" $page.Parent -}}
{{- end -}}
{{- if eq .id $page -}}
{{- $page.Title -}}
{{- else -}}
<a href="{{ $page.RelPermalink }}">{{ $page.Title }}</a> <span class="pointer">» </span>
{{- end -}}
{{- end -}}
{{- end -}}