Minor codestyle fixes to meta_breadcrumb. Moving safeJS to the partial output.
This commit is contained in:
parent
a4b9df99b1
commit
86d7c8d001
1 changed files with 25 additions and 28 deletions
|
|
@ -1,10 +1,10 @@
|
|||
{{- $breadcrumbScratch := newScratch -}}
|
||||
{{- $crumbScratch := newScratch -}}
|
||||
{{- $crumbScratch.Set "itemListElement" (slice) -}}
|
||||
{{- $breadPos := 0 -}}
|
||||
{{- range .Ancestors.Reverse -}}
|
||||
{{- $breadPos = (add $breadPos 1) -}}
|
||||
{{- $crumbScratch.Add "itemListElement" (dict
|
||||
{{ $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
|
||||
|
|
@ -12,9 +12,9 @@
|
|||
"name" .LinkTitle
|
||||
)
|
||||
) -}}
|
||||
{{- end -}}
|
||||
{{- $breadPos = (add $breadPos 1) -}}
|
||||
{{- $crumbScratch.Add "itemListElement" (dict
|
||||
{{ end -}}
|
||||
{{ $breadPos = (add $breadPos 1) -}}
|
||||
{{ $crumbScratch.Add "itemListElement" (dict
|
||||
"@type" "ListItem"
|
||||
"position" $breadPos
|
||||
"item" (dict
|
||||
|
|
@ -22,8 +22,8 @@
|
|||
"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 -}}
|
||||
{{ $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) -}}
|
||||
|
|
|
|||
Loading…
Reference in a new issue