mirror of
https://github.com/McShelby/hugo-theme-relearn.git
synced 2024-12-12 08:54:08 +00:00
56 lines
No EOL
2.2 KiB
HTML
56 lines
No EOL
2.2 KiB
HTML
{{- $page := .page }}
|
|
{{- $to := $page }}
|
|
{{- $pageurl := partial "relLangPrettyUglyURL.hugo" (dict "to" $page) }}
|
|
{{- $lasturl := partial "relLangPrettyUglyURL.hugo" (dict "to" $page) }}
|
|
{{- if .dirOnly }}
|
|
{{- $page = $page.Parent }}
|
|
{{- $to = $page }}
|
|
{{- $lasturl = partial "relLangPrettyUglyURL.hugo" (dict "to" $page) }}
|
|
{{- end }}
|
|
{{- $depth := add 1 (int (partial "get-page-depth.hugo" (dict "page" $page))) }}
|
|
{{- if .page.Site.Params.disableRootBreadcrumb }}
|
|
{{- $depth = add $depth -1 }}
|
|
{{- end }}
|
|
{{- $breadcrumb := slice }}
|
|
{{- range seq $depth }}
|
|
{{- if $to }}
|
|
{{- if (default $to.Data.Term $to.Title) }}
|
|
{{- $breadcrumb = $breadcrumb | append $to }}
|
|
{{- end }}
|
|
{{- else }}
|
|
{{- break }}
|
|
{{- end }}
|
|
{{- $to = $to.Parent }}
|
|
{{- end }}
|
|
{{- $len := len $breadcrumb -}}
|
|
{{- $breadcrumbReversed := slice }}
|
|
{{- range seq $len }}
|
|
{{- $breadcrumbReversed = $breadcrumbReversed | append (index $breadcrumb (sub $len .)) }}
|
|
{{- end }}
|
|
{{- $depth := 0 }}
|
|
{{- range $i, $e := $breadcrumbReversed }}
|
|
{{- $to := $e }}
|
|
{{- $depth = add $depth 1 }}
|
|
{{- $title := $to.Title }}
|
|
{{- if eq $to.Kind "taxonomy" }}
|
|
{{- $title = i18n $to.Data.Plural }}
|
|
{{- if not $title }}
|
|
{{- $title = $to.Data.Plural }}
|
|
{{- end }}
|
|
{{- else if eq $to.Kind "term" }}
|
|
{{- $title = i18n $to.Data.Singular }}
|
|
{{- if not $title }}
|
|
{{- $title = $to.Data.Singular }}
|
|
{{- end }}
|
|
{{- $title = printf "%s %s %s" $title (default "::" .Site.Params.titleSeparator) (default $to.Data.Term $to.Title) }}
|
|
{{- end }}
|
|
{{- if not $title }}
|
|
{{- $title = $to.Site.Title }}
|
|
{{- end }}
|
|
{{- $url := partial "relLangPrettyUglyURL.hugo" (dict "to" $to) }}
|
|
{{- $isPage := eq $url $pageurl }}
|
|
{{- $isLast := eq $url $lasturl }}
|
|
{{- $link := and $url (not $isPage) }}
|
|
{{- printf "<li" | safeHTML }}
|
|
itemscope itemtype="https://schema.org/ListItem" itemprop="itemListElement">{{ if $link }}<a itemprop="item" href="{{ $url }}">{{end}}<span itemprop="name">{{ $title }}</span>{{ if $link }}</a>{{ end }}<meta itemprop="position" content="{{ $depth }}">{{ if not $isLast }}{{ (printf " %s " (default ">" .Site.Params.breadcrumbSeparator)) | safeHTML }}{{ end }}</li>
|
|
{{- end }} |