hacker.tours-website/themes/zen/layouts/partials/meta_breadcrumb_json_ld.html

30 lines
1,014 B
HTML
Raw Normal View History

2024-06-13 22:14:05 +02:00
{{ $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) -}}