From a7519b989709edfbdd5848d3170642013d7568b4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=B6ren=20Weber?= Date: Tue, 28 Nov 2023 22:45:38 +0100 Subject: [PATCH] taxonomy: use title case for fallback term titles #713 --- layouts/_default/index.json | 2 +- layouts/_default/index.search.js | 2 +- layouts/_default/taxonomy.html | 2 +- layouts/_default/term.html | 2 +- layouts/partials/breadcrumbs.html | 2 +- layouts/partials/header.html | 2 +- layouts/partials/opengraph.html | 4 ++-- layouts/partials/term-list.html | 4 ++-- layouts/partials/toc-id.html | 2 +- layouts/partials/twitter_cards.html | 2 +- 10 files changed, 12 insertions(+), 12 deletions(-) diff --git a/layouts/_default/index.json b/layouts/_default/index.json index 217fffcc3c..f460fb9b67 100644 --- a/layouts/_default/index.json +++ b/layouts/_default/index.json @@ -8,7 +8,7 @@ {{- else if eq .Kind "term" }} {{- $taxonomy_page := .Site.GetPage .Data.Plural }} {{- $title = default (default .Data.Singular (i18n .Data.Singular)) $taxonomy_page.Params.SingularTitle }} - {{- $title = printf "%s %s %s" $title (default "::" .Site.Params.titleSeparator) (default (humanize .Data.Term) .Title) }} + {{- $title = printf "%s %s %s" $title (default "::" .Site.Params.titleSeparator) (default (humanize .Data.Term | strings.Title) .Title) }} {{- end }} {{- $pages = $pages | append (dict "uri" (partial "relLangPrettyUglyURL.hugo" (dict "to" .)) diff --git a/layouts/_default/index.search.js b/layouts/_default/index.search.js index 014f30652b..e0951c0350 100644 --- a/layouts/_default/index.search.js +++ b/layouts/_default/index.search.js @@ -8,7 +8,7 @@ {{- else if eq .Kind "term" }} {{- $taxonomy_page := .Site.GetPage .Data.Plural }} {{- $title = default (default .Data.Singular (i18n .Data.Singular)) $taxonomy_page.Params.SingularTitle }} - {{- $title = printf "%s %s %s" $title (default "::" .Site.Params.titleSeparator) (default (humanize .Data.Term) .Title) }} + {{- $title = printf "%s %s %s" $title (default "::" .Site.Params.titleSeparator) (default (humanize .Data.Term | strings.Title) .Title) }} {{- end }} {{- $pages = $pages | append (dict "uri" (partial "relLangPrettyUglyURL.hugo" (dict "to" .)) diff --git a/layouts/_default/taxonomy.html b/layouts/_default/taxonomy.html index 8bc304d63b..bdf1f36b46 100644 --- a/layouts/_default/taxonomy.html +++ b/layouts/_default/taxonomy.html @@ -19,7 +19,7 @@ {{- end }} {{- end }} {{- if $len }} - {{- $pages = $pages| append (dict "Title" (default (humanize .Page.Data.Term) .Page.Title) "Page" . "Len" $len )}} + {{- $pages = $pages| append (dict "Title" (default (humanize .Page.Data.Term | strings.Title) .Page.Title) "Page" . "Len" $len )}} {{- end }} {{- if not .Page.Title }} {{- warnf "%q: You have not given a 'title' in the frontmatter of your term page, the humanized term will be used instead" .Page.File.Filename }} diff --git a/layouts/_default/term.html b/layouts/_default/term.html index 2f95bcc177..e74548a8b5 100644 --- a/layouts/_default/term.html +++ b/layouts/_default/term.html @@ -7,7 +7,7 @@ {{- $taxonomy_page := .Site.GetPage .Data.Plural }} {{- $title := default (default .Data.Singular (i18n .Data.Singular)) $taxonomy_page.Params.SingularTitle }} -{{- $title = printf "%s %s %s" $title (default "::" .Site.Params.titleSeparator) (default (humanize .Data.Term) .Title) }} +{{- $title = printf "%s %s %s" $title (default "::" .Site.Params.titleSeparator) (default (humanize .Data.Term | strings.Title) .Title) }}

{{ $title }}

{{- .Content }} {{- $lastCapital := "" }} diff --git a/layouts/partials/breadcrumbs.html b/layouts/partials/breadcrumbs.html index f8865f3dfa..90a7c5a911 100644 --- a/layouts/partials/breadcrumbs.html +++ b/layouts/partials/breadcrumbs.html @@ -37,7 +37,7 @@ {{- else if eq $to.Kind "term" }} {{- $taxonomy_page := $to.Site.GetPage $to.Data.Plural }} {{- $title = default (default $to.Data.Singular (i18n $to.Data.Singular)) $taxonomy_page.Params.SingularTitle }} - {{- $title = printf "%s %s %s" $title (default "::" $to.Site.Params.titleSeparator) (default (humanize $to.Data.Term) $to.Title) }} + {{- $title = printf "%s %s %s" $title (default "::" $to.Site.Params.titleSeparator) (default (humanize $to.Data.Term | strings.Title) $to.Title) }} {{- end }} {{- if not $title }} {{- $title = $to.Site.Title }} diff --git a/layouts/partials/header.html b/layouts/partials/header.html index 8347e13124..ec0928ad57 100644 --- a/layouts/partials/header.html +++ b/layouts/partials/header.html @@ -24,7 +24,7 @@ {{- else if eq .Kind "term" }} {{- $taxonomy_page := .Site.GetPage .Data.Plural }} {{- $title = default (default .Data.Singular (i18n .Data.Singular)) $taxonomy_page.Params.SingularTitle }} - {{- $title = printf "%s %s %s" (default (humanize .Data.Term) .Title) (default "::" .Site.Params.titleSeparator) $title }} + {{- $title = printf "%s %s %s" (default (humanize .Data.Term | strings.Title) .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 }} diff --git a/layouts/partials/opengraph.html b/layouts/partials/opengraph.html index 13a51f35d9..36fabffae9 100644 --- a/layouts/partials/opengraph.html +++ b/layouts/partials/opengraph.html @@ -14,7 +14,7 @@ {{- else if eq .Kind "term" }} {{- $taxonomy_page := .Site.GetPage .Data.Plural }} {{- $title = default (default .Data.Singular (i18n .Data.Singular)) $taxonomy_page.Params.SingularTitle }} - {{- $title = printf "%s %s %s" (default (humanize .Data.Term) .Title) (default "::" .Site.Params.titleSeparator) $title }} + {{- $title = printf "%s %s %s" (default (humanize .Data.Term | strings.Title) .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 }} @@ -54,7 +54,7 @@ {{- else if eq .Kind "term" }} {{- $taxonomy_page := .Site.GetPage .Data.Plural }} {{- $title = default (default .Data.Singular (i18n .Data.Singular)) $taxonomy_page.Params.SingularTitle }} - {{- $title = printf "%s %s %s" (default (humanize .Data.Term) .Title) (default "::" .Site.Params.titleSeparator) $title }} + {{- $title = printf "%s %s %s" (default (humanize .Data.Term | strings.Title) .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 }} diff --git a/layouts/partials/term-list.html b/layouts/partials/term-list.html index a0680cf365..a38aa15650 100644 --- a/layouts/partials/term-list.html +++ b/layouts/partials/term-list.html @@ -21,11 +21,11 @@ {{- end }} {{- $term_key := ($term | plainify | anchorize) }} {{- with $page.Site.GetPage (printf "%s/%s" $taxonomy $term_key) }} - {{- $term_pages = $term_pages | append (dict "Title" (default (humanize .Data.Term) .Title) "Term" . )}} + {{- $term_pages = $term_pages | append (dict "Title" (default (humanize .Data.Term | strings.Title) .Title) "Term" . )}} {{- else }} {{- $term_key = ($term | urlize) }} {{- with $page.Site.GetPage (printf "%s/%s" $taxonomy $term_key) }} - {{- $term_pages = $term_pages | append (dict "Title" (default (humanize .Data.Term) .Title) "Term" . )}} + {{- $term_pages = $term_pages | append (dict "Title" (default (humanize .Data.Term | strings.Title) .Title) "Term" . )}} {{- end }} {{- end }} {{- end }} diff --git a/layouts/partials/toc-id.html b/layouts/partials/toc-id.html index 94ca1ef6e9..8c54d26183 100644 --- a/layouts/partials/toc-id.html +++ b/layouts/partials/toc-id.html @@ -11,7 +11,7 @@ {{- end }} {{- end }} {{- if $len }} - {{- $pages = $pages| append (dict "Title" (default (humanize .Page.Data.Term) .Page.Title) "Page" . "Len" $len )}} + {{- $pages = $pages| append (dict "Title" (default (humanize .Page.Data.Term | strings.Title) .Page.Title) "Page" . "Len" $len )}} {{- end }} {{- end }} {{- else if eq .Kind "term" }} diff --git a/layouts/partials/twitter_cards.html b/layouts/partials/twitter_cards.html index 47ed0d4f95..1e110ff5fa 100644 --- a/layouts/partials/twitter_cards.html +++ b/layouts/partials/twitter_cards.html @@ -10,7 +10,7 @@ {{- else if eq .Kind "term" }} {{- $taxonomy_page := .Site.GetPage .Data.Plural }} {{- $title = default (default .Data.Singular (i18n .Data.Singular)) $taxonomy_page.Params.SingularTitle }} - {{- $title = printf "%s %s %s" (default (humanize .Data.Term) .Title) (default "::" .Site.Params.titleSeparator) $title }} + {{- $title = printf "%s %s %s" (default (humanize .Data.Term | strings.Title) .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 }}