1

Gestion du JSON-LD

This commit is contained in:
2026-03-16 21:21:27 +01:00
parent 7676fe3e22
commit b518d573bc
14 changed files with 275 additions and 8 deletions

View File

@@ -0,0 +1,23 @@
{{- $page := . -}}
{{- with .Page -}}
{{- $page = . -}}
{{- end -}}
{{- $trail := slice $page.Site.Home -}}
{{- if $page -}}
{{- range $page.Ancestors.Reverse -}}
{{- if ne .RelPermalink "/" -}}
{{- $trail = $trail | append . -}}
{{- end -}}
{{- end -}}
{{- if eq $page.Kind "term" -}}
{{- with site.GetPage "taxonomy" $page.Data.Plural -}}
{{- if not (in $trail .) -}}
{{- $trail = $trail | append . -}}
{{- end -}}
{{- end -}}
{{- end -}}
{{- if ne $page.RelPermalink "/" -}}
{{- $trail = $trail | append $page -}}
{{- end -}}
{{- end -}}
{{- return $trail -}}

View File

@@ -0,0 +1,19 @@
{{- $socialImage := partial "head/social-image.html" . -}}
{{- $openGraphImage := $socialImage.openGraph -}}
{{- $image := dict -}}
{{- with $openGraphImage.url -}}
{{- $image = dict
"@type" "ImageObject"
"url" .
-}}
{{- with $openGraphImage.width -}}
{{- $image = merge $image (dict "width" .) -}}
{{- end -}}
{{- with $openGraphImage.height -}}
{{- $image = merge $image (dict "height" .) -}}
{{- end -}}
{{- with $openGraphImage.alt -}}
{{- $image = merge $image (dict "caption" .) -}}
{{- end -}}
{{- end -}}
{{- return $image -}}

View File

@@ -0,0 +1,10 @@
{{- $searchPath := site.Params.search.action | relURL -}}
{{- $noindex := eq .RelPermalink $searchPath -}}
{{- if not $noindex -}}
{{- with .Params.seo -}}
{{- with index . "noindex" -}}
{{- $noindex = . -}}
{{- end -}}
{{- end -}}
{{- end -}}
{{- return $noindex -}}

View File

@@ -0,0 +1,47 @@
{{- $classification := dict
"openGraphType" "website"
"isArticleLike" false
"jsonLdType" "WebPage"
"reviewedType" ""
-}}
{{- if .IsPage -}}
{{- if in (slice "interets" "prompted") .Section -}}
{{- $classification = merge $classification (dict
"openGraphType" "article"
"isArticleLike" true
"jsonLdType" "BlogPosting"
) -}}
{{- else if eq .Section "critiques" -}}
{{- $reviewedType := "CreativeWork" -}}
{{- with .CurrentSection -}}
{{- if eq .RelPermalink "/critiques/films/" -}}
{{- $reviewedType = "Movie" -}}
{{- else if eq .RelPermalink "/critiques/jeux-video/" -}}
{{- $reviewedType = "VideoGame" -}}
{{- else if eq .RelPermalink "/critiques/livres/" -}}
{{- $reviewedType = "Book" -}}
{{- else if eq .RelPermalink "/critiques/series/" -}}
{{- $reviewedType = "TVSeries" -}}
{{- end -}}
{{- end -}}
{{- $classification = merge $classification (dict
"openGraphType" "article"
"isArticleLike" true
"jsonLdType" "Review"
"reviewedType" $reviewedType
) -}}
{{- else if eq .Section "collections" -}}
{{- $classification = merge $classification (dict
"openGraphType" "article"
"isArticleLike" true
"jsonLdType" "Article"
) -}}
{{- end -}}
{{- else if not .IsHome -}}
{{- $classification = merge $classification (dict
"jsonLdType" "CollectionPage"
) -}}
{{- end -}}
{{- return $classification -}}

View File

@@ -0,0 +1,8 @@
{{- $authorID := printf "%s#author" .Site.Home.Permalink -}}
{{- $person := dict
"@type" "Person"
"@id" $authorID
"name" .Site.Title
"url" .Site.Home.Permalink
-}}
{{- return $person -}}