refactor json-ld
parent
e10e931b69
commit
21135a9fda
|
@ -1,26 +1,21 @@
|
||||||
{{- define "partials/parents.html" -}}
|
{{- $breadcrumbs := slice -}}
|
||||||
{{- $parents := slice . -}}
|
{{- range $index, $page := .Ancestors.Reverse -}}
|
||||||
{{- if .Parent -}}
|
{{-
|
||||||
{{- $parents = partial "parents.html" .Parent | append $parents -}}
|
$item := dict
|
||||||
{{- end -}}
|
"@type" "ListItem"
|
||||||
{{- return $parents -}}
|
"position" (add $index 1)
|
||||||
|
"item" (dict "@id" $page.Permalink "name" $page.Title)
|
||||||
|
-}}
|
||||||
|
{{- $breadcrumbs = $breadcrumbs | append $item -}}
|
||||||
{{- end -}}
|
{{- end -}}
|
||||||
{{- define "partials/breadcrumb-items.html" -}}
|
{{-
|
||||||
{{- $items := slice -}}
|
$breadcrumbs = $breadcrumbs | append (
|
||||||
{{- range $index, $page := partial "parents" . -}}
|
dict
|
||||||
{{- if eq $index 0 -}}
|
"@type" "ListItem"
|
||||||
{{- continue -}}
|
"position" ($breadcrumbs | len | add 1)
|
||||||
{{- end -}}
|
"item" (dict "@id" .Permalink "name" .Title)
|
||||||
{{-
|
)
|
||||||
$item := dict
|
-}}
|
||||||
"@type" "ListItem"
|
|
||||||
"position" $index
|
|
||||||
"item" (dict "@id" $page.Permalink "name" $page.Title)
|
|
||||||
-}}
|
|
||||||
{{- $items = $items | append $item -}}
|
|
||||||
{{- end -}}
|
|
||||||
{{- return $items -}}
|
|
||||||
{{- end }}
|
|
||||||
{{- $about := ref . "about" -}}
|
{{- $about := ref . "about" -}}
|
||||||
{{-
|
{{-
|
||||||
$publisher := dict
|
$publisher := dict
|
||||||
|
@ -86,7 +81,7 @@ $article := dict
|
||||||
$breadcrumbs := dict
|
$breadcrumbs := dict
|
||||||
"@context" "https://schema.org"
|
"@context" "https://schema.org"
|
||||||
"@type" "BreadcrumbList"
|
"@type" "BreadcrumbList"
|
||||||
"itemListElement" (partial "breadcrumb-items" .)
|
"itemListElement" $breadcrumbs
|
||||||
-}}
|
-}}
|
||||||
{{-
|
{{-
|
||||||
$website := dict
|
$website := dict
|
||||||
|
|
Loading…
Reference in New Issue