From c975dfd2de95d35c3077c16c3de66e81fcfc19b2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=B6ren=20Weber?= Date: Thu, 18 May 2023 14:03:39 +0200 Subject: [PATCH] theme: make sure to display well with no theme specific params set #516 --- exampleSite/layouts/partials/shortcodes/piratify.html | 9 ++++++++- layouts/404.html | 10 ++++++---- layouts/partials/header.html | 2 +- 3 files changed, 15 insertions(+), 6 deletions(-) diff --git a/exampleSite/layouts/partials/shortcodes/piratify.html b/exampleSite/layouts/partials/shortcodes/piratify.html index 4098182259..0a5a67ec94 100644 --- a/exampleSite/layouts/partials/shortcodes/piratify.html +++ b/exampleSite/layouts/partials/shortcodes/piratify.html @@ -6,8 +6,15 @@ {{- $langsrc := cond (eq $context.Lang $langtrg) (.langsrc | default "en") $context.Lang }} {{- $baseURL := urls.Parse site.BaseURL }} {{- $baseURLpath := $baseURL.Path | default "/" }} -{{- $l := "" }} +{{- $l := $context.RelPermalink }} {{- $c := "" }} +{{- if ne $content nil }} + {{- $c = $content }} +{{- else if eq $pagefield "Content" }} + {{- $c = $context.Content }} +{{- else if eq $pagefield "TableOfContents" }} + {{- $c = $context.TableOfContents }} +{{- end }} {{- range $context.AllTranslations }} {{- if eq .Language.Lang $langsrc }} {{- $l = .RelPermalink }} diff --git a/layouts/404.html b/layouts/404.html index 595258d338..0cd3b8d7a1 100644 --- a/layouts/404.html +++ b/layouts/404.html @@ -5,12 +5,14 @@ {{- partial "meta.html" . }} {{- .Scratch.Add "title" "" }} + {{- $title := .Title }} {{- if eq .Site.Data.titles .Title }} - {{- .Scratch.Set "title" (index .Site.Data.titles .Title).title }} - {{- else }} - {{- .Scratch.Set "title" .Title}} + {{- $title = (index .Site.Data.titles .Title).title }} {{- end }} - {{ .Scratch.Get "title" }} {{ default "::" .Site.Params.titleSeparator }} {{ .Site.Title }} + {{- if and $title .Site.Title (not (eq $title .Site.Title)) }} + {{- $title = printf "%s %s %s" $title (default "::" .Site.Params.titleSeparator) .Site.Title }} + {{- end }} + {{ $title }} {{- partialCached "favicon.html" . }} {{- partialCached "stylesheet.html" (dict "page" . "outputFormat" $outputFormat) $outputFormat }} diff --git a/layouts/partials/header.html b/layouts/partials/header.html index 90efba22ec..4e71f49f00 100644 --- a/layouts/partials/header.html +++ b/layouts/partials/header.html @@ -16,7 +16,7 @@ {{- else if eq .Kind "term" }} {{- $title = printf "%s %s" (.Data.Singular | humanize) $title }} {{- end }} - {{- if and $title (not (eq $title .Site.Title)) }} + {{- if and $title .Site.Title (not (eq $title .Site.Title)) }} {{- $title = printf "%s %s %s" $title (default "::" .Site.Params.titleSeparator) .Site.Title }} {{- end }} {{ $title }}