From 7733deb0e1f22b3ec28aed0eb68875936f7c2f78 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=B6ren=20Weber?= Date: Wed, 11 Oct 2023 17:41:04 +0200 Subject: [PATCH] theme: fix URL fro opengraph #683 --- layouts/partials/opengraph.html | 42 ++++++++++++++++++--------------- 1 file changed, 23 insertions(+), 19 deletions(-) diff --git a/layouts/partials/opengraph.html b/layouts/partials/opengraph.html index f49806d149..47be47c567 100644 --- a/layouts/partials/opengraph.html +++ b/layouts/partials/opengraph.html @@ -1,6 +1,10 @@ {{- /* based on Hugo 0.119.0 _internal/opengraph.html but with modified title */}} {{- $format := partial "get-format.hugo" . }} {{- $outputFormat := partial "output-format.hugo" (dict "page" . "format" $format) }} +{{- $basename := "index" }} +{{- if eq $outputFormat "searchpage" }} + {{- $basename = partial "BaseName.hugo" $format.RelPermalink }} +{{- end }} {{- $page := . }} {{- $title := .Title }} {{- if eq $outputFormat "searchpage" }} @@ -23,7 +27,7 @@ - + {{- with $.Params.images }} {{- range first 6 . }} @@ -45,26 +49,26 @@ {{- if .IsPage }} {{- $iso8601 := "2006-01-02T15:04:05-07:00" }} {{- with .Parent }} - {{- $page := . }} - {{- $link := "" }} - {{- $title := .Title }} - {{- if eq $outputFormat "searchpage" }} - {{- $title = T "Search" }} - {{- else if eq .Kind "taxonomy" }} - {{- $title = i18n .Data.Plural }} - {{- if not $title }} - {{- $title = .Data.Plural }} + {{- $page := . }} + {{- $link := "" }} + {{- $title := .Title }} + {{- if eq $outputFormat "searchpage" }} + {{- $title = T "Search" }} + {{- else if eq .Kind "taxonomy" }} + {{- $title = i18n .Data.Plural }} + {{- if not $title }} + {{- $title = .Data.Plural }} + {{- end }} + {{- else if eq .Kind "term" }} + {{- $title = i18n .Data.Singular }} + {{- if not $title }} + {{- $title = .Data.Singular }} + {{- end }} + {{- $title = printf "%s %s %s" .Title (default "::" .Site.Params.titleSeparator) $title }} {{- end }} - {{- else if eq .Kind "term" }} - {{- $title = i18n .Data.Singular }} - {{- if not $title }} - {{- $title = .Data.Singular }} + {{- if and $title .Site.Title (not (eq $title .Site.Title)) }} + {{- $title = printf "%s %s %s" $title (default "::" .Site.Params.titleSeparator) .Site.Title }} {{- end }} - {{- $title = printf "%s %s %s" .Title (default "::" .Site.Params.titleSeparator) $title }} - {{- end }} - {{- if and $title .Site.Title (not (eq $title .Site.Title)) }} - {{- $title = printf "%s %s %s" $title (default "::" .Site.Params.titleSeparator) .Site.Title }} - {{- end }} {{- end }} {{- with .PublishDate }}