| 1 |
<!-- Copied from Docsy and modified to emit schema.org metadata --> |
| 2 |
|
| 3 |
{{ $isSingle := true -}} |
| 4 |
{{ with .Parent -}} |
| 5 |
{{ $isSingle = .IsHome -}} |
| 6 |
{{ end -}} |
| 7 |
|
| 8 |
|
| 9 |
{{ .Scratch.Set "breadcrumbMaxDepth" 0 }} |
| 10 |
{{ template "breadcrumbcount" (dict "p1" . "scratch" .Scratch) }} |
| 11 |
{{ define "breadcrumbcount" }} |
| 12 |
{{ .scratch.Set "breadcrumbMaxDepth" (add 1 (.scratch.Get "breadcrumbMaxDepth")) }} |
| 13 |
{{ if .p1.Parent }} |
| 14 |
{{ if not .p1.Parent.IsHome }} |
| 15 |
{{ template "breadcrumbcount" (dict "p1" .p1.Parent "scratch" .scratch) }} |
| 16 |
{{ end }} |
| 17 |
{{ else if not .IsHome }} |
| 18 |
{{ template "breadcrumbcount" (dict "p1" .p1.Site.Home "scratch" .scratch) }} |
| 19 |
{{ end }} |
| 20 |
{{ end }} |
| 21 |
|
| 22 |
|
| 23 |
<nav aria-label="breadcrumb" class="td-breadcrumbs |
| 24 |
{{- if $isSingle }} td-breadcrumbs__single {{- end }}"> |
| 25 |
<ol class="breadcrumb" itemscope itemtype="https://schema.org/BreadcrumbList"> |
| 26 |
{{- template "breadcrumbnav" (dict "p1" . "p2" . "depth" 0 "scratch" .Scratch) }} |
| 27 |
</ol> |
| 28 |
</nav> |
| 29 |
|
| 30 |
{{- define "breadcrumbnav" -}} |
| 31 |
{{ if .p1.Parent -}} |
| 32 |
{{ if not .p1.Parent.IsHome -}} |
| 33 |
{{ template "breadcrumbnav" (dict "p1" .p1.Parent "p2" .p2 "depth" (add .depth 1) "scratch" .scratch) -}} |
| 34 |
{{ end -}} |
| 35 |
{{ else if not .p1.IsHome -}} |
| 36 |
{{ template "breadcrumbnav" (dict "p1" .p1.Site.Home "p2" .p2 "depth" (add .depth 1) "scratch" .scratch) -}} |
| 37 |
{{ end -}} |
| 38 |
{{ $isActive := eq .p1 .p2 }} |
| 39 |
<li itemprop="itemListElement" itemscope itemtype="https://schema.org/ListItem" class="breadcrumb-item{{ if $isActive }} active{{ end }}" |
| 40 |
{{- if $isActive }} aria-current="page"{{ end }}> |
| 41 |
<a itemprop="item" href="{{ .p1.Permalink }}" |
| 42 |
{{- if $isActive }} aria-disabled="true" class="btn-link disabled"{{ end -}} |
| 43 |
> |
| 44 |
<span itemprop="name">{{- .p1.LinkTitle -}}</span> |
| 45 |
</a> |
| 46 |
<meta itemprop="position" content="{{ sub (.scratch.Get "breadcrumbMaxDepth") .depth }} " /> |
| 47 |
</li> |
| 48 |
{{- end -}} |