summaryrefslogtreecommitdiff
path: root/layouts
diff options
context:
space:
mode:
authorSangeeth Sudheer <git@sangeeth.dev>2025-03-07 10:19:49 +0530
committerSangeeth Sudheer <git@sangeeth.dev>2025-03-09 01:50:55 +0530
commitc7188632b728bff9caf3bb0b9746e662f2eddee1 (patch)
treee8df4a97d88a1b2ddae7e4e133ac57dbd0761cf1 /layouts
parentda22bc00a46bf3d0539bae77da9d278bc1131e02 (diff)
Add breadcrumbs config to hide current page and change home text
Changes `breadcrumbs` config into an object to add customizations such as hiding current page and changing the text of the home crumb. By default, Typo will now show breadcrumbs. If breadcrumbs are enabled, the current default of showing the current page crumb is preserved. BREAKING CHANGE: `breadcrumbs` is now an object so existing `breadcrumbs = <true/false>` line in config needs to be changed.
Diffstat (limited to 'layouts')
-rw-r--r--layouts/partials/breadcrumbs.html28
1 files changed, 21 insertions, 7 deletions
diff --git a/layouts/partials/breadcrumbs.html b/layouts/partials/breadcrumbs.html
index 5c4fb62..df67cb8 100644
--- a/layouts/partials/breadcrumbs.html
+++ b/layouts/partials/breadcrumbs.html
@@ -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 }} \ No newline at end of file
+{{- end -}} \ No newline at end of file