Skip to content

Commit

Permalink
taxonomy: use title case for fallback term titles #713
Browse files Browse the repository at this point in the history
  • Loading branch information
McShelby committed Nov 28, 2023
1 parent f9f3447 commit a7519b9
Show file tree
Hide file tree
Showing 10 changed files with 12 additions and 12 deletions.
2 changes: 1 addition & 1 deletion layouts/_default/index.json
Original file line number Diff line number Diff line change
Expand Up @@ -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" .))
Expand Down
2 changes: 1 addition & 1 deletion layouts/_default/index.search.js
Original file line number Diff line number Diff line change
Expand Up @@ -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" .))
Expand Down
2 changes: 1 addition & 1 deletion layouts/_default/taxonomy.html
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ <h1 id="{{ $title | plainify | anchorize }}">{{ $title }}</h1>
{{- 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 }}
Expand Down
2 changes: 1 addition & 1 deletion layouts/_default/term.html
Original file line number Diff line number Diff line change
Expand Up @@ -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) }}
<h1 id="{{ $title | plainify | anchorize }}">{{ $title }}</h1>
{{- .Content }}
{{- $lastCapital := "" }}
Expand Down
2 changes: 1 addition & 1 deletion layouts/partials/breadcrumbs.html
Original file line number Diff line number Diff line change
Expand Up @@ -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 }}
Expand Down
2 changes: 1 addition & 1 deletion layouts/partials/header.html
Original file line number Diff line number Diff line change
Expand Up @@ -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 }}
Expand Down
4 changes: 2 additions & 2 deletions layouts/partials/opengraph.html
Original file line number Diff line number Diff line change
Expand Up @@ -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 }}
Expand Down Expand Up @@ -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 }}
Expand Down
4 changes: 2 additions & 2 deletions layouts/partials/term-list.html
Original file line number Diff line number Diff line change
Expand Up @@ -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 }}
Expand Down
2 changes: 1 addition & 1 deletion layouts/partials/toc-id.html
Original file line number Diff line number Diff line change
Expand Up @@ -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" }}
Expand Down
2 changes: 1 addition & 1 deletion layouts/partials/twitter_cards.html
Original file line number Diff line number Diff line change
Expand Up @@ -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 }}
Expand Down

0 comments on commit a7519b9

Please sign in to comment.