29 lines
1,014 B
HTML
29 lines
1,014 B
HTML
{{ $breadcrumbScratch := newScratch -}}
|
|
{{ $crumbScratch := newScratch -}}
|
|
{{ $crumbScratch.Set "itemListElement" (slice) -}}
|
|
{{ $breadPos := 0 -}}
|
|
{{ range .Ancestors.Reverse -}}
|
|
{{ $breadPos = (add $breadPos 1) -}}
|
|
{{ $crumbScratch.Add "itemListElement" (dict
|
|
"@type" "ListItem"
|
|
"position" $breadPos
|
|
"item" (dict
|
|
"@id" .Permalink
|
|
"name" .LinkTitle
|
|
)
|
|
) -}}
|
|
{{ end -}}
|
|
{{ $breadPos = (add $breadPos 1) -}}
|
|
{{ $crumbScratch.Add "itemListElement" (dict
|
|
"@type" "ListItem"
|
|
"position" $breadPos
|
|
"item" (dict
|
|
"@id" .Permalink
|
|
"name" .LinkTitle
|
|
)
|
|
) -}}
|
|
{{ $breadcrumbScratch.SetInMap "breadcrumb" "@context" "https://schema.org" -}}
|
|
{{ $breadcrumbScratch.SetInMap "breadcrumb" "@type" "BreadcrumbList" -}}
|
|
{{ $breadcrumbScratch.SetInMap "breadcrumb" "itemListElement" ($crumbScratch.Get "itemListElement") -}}
|
|
{{ $jsonifiedBreadcrumb := $breadcrumbScratch.Get "breadcrumb" | jsonify (dict "indent" " " "prefix" " ") -}}
|
|
{{ return ($jsonifiedBreadcrumb | safeJS) -}}
|