hacker.tours-website/themes/zen/layouts/partials/meta_breadcrumb_json_ld.html
2024-06-13 22:14:05 +02:00

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) -}}