Merge pull request #95 from runofthemillgeek/feat/breadcrumbs-customization

Add breadcrumbs config to hide current page and change home text
This commit is contained in:
Francesco Tomaselli 2025-03-14 21:06:32 +01:00 committed by GitHub
commit 338510e751
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
6 changed files with 47 additions and 16 deletions

View file

@ -1,9 +1,23 @@
{{ if .Site.Params.breadcrumbs }}
{{- if .Site.Params.breadcrumbs.enabled -}}
{{- $breadcrumbs := .Site.Params.breadcrumbs -}}
<div class="breadcrumbs">
{{ range .Ancestors.Reverse }}
<a href="{{ .RelPermalink }}">{{ .Title }}</a>
<span class="breadcrumbs-separator"> / </span>
{{ end }}
<a href="{{ .RelPermalink }}">{{ .Title }}</a>
{{- range $i, $v := .Ancestors.Reverse -}}
<a href="{{ .RelPermalink }}">
{{- if (and (eq $i 0) (ne $breadcrumbs.home "")) -}}
{{- $breadcrumbs.home -}}
{{- else -}}
{{- .Title -}}
{{- end -}}
</a>
{{- if (lt $i (sub $.Ancestors.Len 1)) -}}
<span class="breadcrumbs-separator">/</span>
{{- end -}}
{{- end -}}
{{- if $breadcrumbs.showCurrentPage -}}
<span class="breadcrumbs-separator">/</span>
<a href="{{ .RelPermalink }}">{{ .Title }}</a>
{{- end -}}
</div>
{{ end }}
{{- end -}}