taxonomy: lookup title from overridden taxonomy page #712

This commit is contained in:
Sören Weber 2023-11-03 22:50:02 +01:00
parent 4ebb6d9eac
commit 34b8804977
No known key found for this signature in database
GPG key ID: BEC6D55545451B6D
11 changed files with 39 additions and 65 deletions

View file

@ -0,0 +1,8 @@
+++
+++
You can define optional content in your overridden taxonomy page. Aswell you can define optional `title` and `singulartitle` that will override the values from your `config.toml` or of your translation files.
## Just an example heading
The TOC will contain this heading and the index headings below.

View file

@ -0,0 +1,5 @@
+++
title = "Tag-a-taggs"
singulartitle = "Tagga"
+++
{{< piratify >}}

View file

@ -4,15 +4,10 @@
{{- if and .Title .RelPermalink (or (ne (.Scratch.Get "relearnIsHiddenStem") true) (ne .Site.Params.disableSearchHiddenPages true) ) }} {{- if and .Title .RelPermalink (or (ne (.Scratch.Get "relearnIsHiddenStem") true) (ne .Site.Params.disableSearchHiddenPages true) ) }}
{{- $title := .Title }} {{- $title := .Title }}
{{- if eq .Kind "taxonomy" }} {{- if eq .Kind "taxonomy" }}
{{- $title = i18n .Data.Plural }} {{- $title = default (default .Data.Plural (i18n .Data.Plural)) .Title }}
{{- if not $title }}
{{- $title = .Data.Plural }}
{{- end }}
{{- else if eq .Kind "term" }} {{- else if eq .Kind "term" }}
{{- $title = i18n .Data.Singular }} {{- $taxonomy_page := .Site.GetPage .Data.Plural }}
{{- if not $title }} {{- $title = default (default .Data.Singular (i18n .Data.Singular)) $taxonomy_page.Params.SingularTitle }}
{{- $title = .Data.Singular }}
{{- end }}
{{- $title = printf "%s %s %s" $title (default "::" .Site.Params.titleSeparator) (default .Data.Term .Title) }} {{- $title = printf "%s %s %s" $title (default "::" .Site.Params.titleSeparator) (default .Data.Term .Title) }}
{{- end }} {{- end }}
{{- $pages = $pages | append (dict {{- $pages = $pages | append (dict

View file

@ -4,15 +4,10 @@
{{- if and .Title .RelPermalink (or (ne (.Scratch.Get "relearnIsHiddenStem") true) (ne .Site.Params.disableSearchHiddenPages true) ) }} {{- if and .Title .RelPermalink (or (ne (.Scratch.Get "relearnIsHiddenStem") true) (ne .Site.Params.disableSearchHiddenPages true) ) }}
{{- $title := .Title }} {{- $title := .Title }}
{{- if eq .Kind "taxonomy" }} {{- if eq .Kind "taxonomy" }}
{{- $title = i18n .Data.Plural }} {{- $title = default (default .Data.Plural (i18n .Data.Plural)) .Title }}
{{- if not $title }}
{{- $title = .Data.Plural }}
{{- end }}
{{- else if eq .Kind "term" }} {{- else if eq .Kind "term" }}
{{- $title = i18n .Data.Singular }} {{- $taxonomy_page := .Site.GetPage .Data.Plural }}
{{- if not $title }} {{- $title = default (default .Data.Singular (i18n .Data.Singular)) $taxonomy_page.Params.SingularTitle }}
{{- $title = .Data.Singular }}
{{- end }}
{{- $title = printf "%s %s %s" $title (default "::" .Site.Params.titleSeparator) (default .Data.Term .Title) }} {{- $title = printf "%s %s %s" $title (default "::" .Site.Params.titleSeparator) (default .Data.Term .Title) }}
{{- end }} {{- end }}
{{- $pages = $pages | append (dict {{- $pages = $pages | append (dict

View file

@ -5,10 +5,7 @@
</header> </header>
{{- $page := . }} {{- $page := . }}
{{- $title := i18n .Data.Plural }} {{- $title := default (default .Data.Plural (i18n .Data.Plural)) .Title }}
{{- if not $title }}
{{- $title = .Data.Plural }}
{{- end }}
<h1 id="{{ $title | plainify | anchorize }}">{{ $title }}</h1> <h1 id="{{ $title | plainify | anchorize }}">{{ $title }}</h1>
{{- $lastCapital := "" }} {{- $lastCapital := "" }}
{{- $terms := slice }} {{- $terms := slice }}

View file

@ -5,10 +5,8 @@
</header> </header>
{{- $page := . }} {{- $page := . }}
{{- $title := i18n .Data.Singular }} {{- $taxonomy_page := .Site.GetPage .Data.Plural }}
{{- if not $title }} {{- $title := default (default .Data.Singular (i18n .Data.Singular)) $taxonomy_page.Params.SingularTitle }}
{{- $title = .Data.Singular }}
{{- end }}
{{- $title = printf "%s %s %s" $title (default "::" .Site.Params.titleSeparator) (default .Data.Term .Title) }} {{- $title = printf "%s %s %s" $title (default "::" .Site.Params.titleSeparator) (default .Data.Term .Title) }}
<h1 id="{{ $title | plainify | anchorize }}">{{ $title }}</h1> <h1 id="{{ $title | plainify | anchorize }}">{{ $title }}</h1>
{{- .Content }} {{- .Content }}

View file

@ -33,15 +33,10 @@
{{- $depth = add $depth 1 }} {{- $depth = add $depth 1 }}
{{- $title := $to.Title }} {{- $title := $to.Title }}
{{- if eq $to.Kind "taxonomy" }} {{- if eq $to.Kind "taxonomy" }}
{{- $title = i18n $to.Data.Plural }} {{- $title = default (default .Data.Plural (i18n .Data.Plural)) .Title }}
{{- if not $title }}
{{- $title = $to.Data.Plural }}
{{- end }}
{{- else if eq $to.Kind "term" }} {{- else if eq $to.Kind "term" }}
{{- $title = i18n $to.Data.Singular }} {{- $taxonomy_page := .Site.GetPage .Data.Plural }}
{{- if not $title }} {{- $title = default (default .Data.Singular (i18n .Data.Singular)) $taxonomy_page.Params.SingularTitle }}
{{- $title = $to.Data.Singular }}
{{- end }}
{{- $title = printf "%s %s %s" $title (default "::" .Site.Params.titleSeparator) (default $to.Data.Term $to.Title) }} {{- $title = printf "%s %s %s" $title (default "::" .Site.Params.titleSeparator) (default $to.Data.Term $to.Title) }}
{{- end }} {{- end }}
{{- if not $title }} {{- if not $title }}

View file

@ -14,15 +14,10 @@
{{- if eq $outputFormat "searchpage" }} {{- if eq $outputFormat "searchpage" }}
{{- $title = T "Search" }} {{- $title = T "Search" }}
{{- else if eq .Kind "taxonomy" }} {{- else if eq .Kind "taxonomy" }}
{{- $title = i18n .Data.Plural }} {{- $title = default (default .Data.Plural (i18n .Data.Plural)) .Title }}
{{- if not $title }}
{{- $title = .Data.Plural }}
{{- end }}
{{- else if eq .Kind "term" }} {{- else if eq .Kind "term" }}
{{- $title = i18n .Data.Singular }} {{- $taxonomy_page := .Site.GetPage .Data.Plural }}
{{- if not $title }} {{- $title = default (default .Data.Singular (i18n .Data.Singular)) $taxonomy_page.Params.SingularTitle }}
{{- $title = .Data.Singular }}
{{- end }}
{{- $title = printf "%s %s %s" (default .Data.Term .Title) (default "::" .Site.Params.titleSeparator) $title }} {{- $title = printf "%s %s %s" (default .Data.Term .Title) (default "::" .Site.Params.titleSeparator) $title }}
{{- end }} {{- end }}
{{- if and $title .Site.Title (not (eq $title .Site.Title)) }} {{- if and $title .Site.Title (not (eq $title .Site.Title)) }}

View file

@ -10,15 +10,10 @@
{{- if eq $outputFormat "searchpage" }} {{- if eq $outputFormat "searchpage" }}
{{- $title = T "Search" }} {{- $title = T "Search" }}
{{- else if eq .Kind "taxonomy" }} {{- else if eq .Kind "taxonomy" }}
{{- $title = i18n .Data.Plural }} {{- $title = default (default .Data.Plural (i18n .Data.Plural)) .Title }}
{{- if not $title }}
{{- $title = .Data.Plural }}
{{- end }}
{{- else if eq .Kind "term" }} {{- else if eq .Kind "term" }}
{{- $title = i18n .Data.Singular }} {{- $taxonomy_page := .Site.GetPage .Data.Plural }}
{{- if not $title }} {{- $title = default (default .Data.Singular (i18n .Data.Singular)) $taxonomy_page.Params.SingularTitle }}
{{- $title = .Data.Singular }}
{{- end }}
{{- $title = printf "%s %s %s" (default .Data.Term .Title) (default "::" .Site.Params.titleSeparator) $title }} {{- $title = printf "%s %s %s" (default .Data.Term .Title) (default "::" .Site.Params.titleSeparator) $title }}
{{- end }} {{- end }}
{{- if and $title .Site.Title (not (eq $title .Site.Title)) }} {{- if and $title .Site.Title (not (eq $title .Site.Title)) }}
@ -55,15 +50,10 @@
{{- if eq $outputFormat "searchpage" }} {{- if eq $outputFormat "searchpage" }}
{{- $title = T "Search" }} {{- $title = T "Search" }}
{{- else if eq .Kind "taxonomy" }} {{- else if eq .Kind "taxonomy" }}
{{- $title = i18n .Data.Plural }} {{- $title = default (default .Data.Plural (i18n .Data.Plural)) .Title }}
{{- if not $title }}
{{- $title = .Data.Plural }}
{{- end }}
{{- else if eq .Kind "term" }} {{- else if eq .Kind "term" }}
{{- $title = i18n .Data.Singular }} {{- $taxonomy_page := .Site.GetPage .Data.Plural }}
{{- if not $title }} {{- $title = default (default .Data.Singular (i18n .Data.Singular)) $taxonomy_page.Params.SingularTitle }}
{{- $title = .Data.Singular }}
{{- end }}
{{- $title = printf "%s %s %s" (default .Data.Term .Title) (default "::" .Site.Params.titleSeparator) $title }} {{- $title = printf "%s %s %s" (default .Data.Term .Title) (default "::" .Site.Params.titleSeparator) $title }}
{{- end }} {{- end }}
{{- if and $title .Site.Title (not (eq $title .Site.Title)) }} {{- if and $title .Site.Title (not (eq $title .Site.Title)) }}

View file

@ -29,8 +29,9 @@
{{- end }} {{- end }}
{{- end }} {{- end }}
{{- end }} {{- end }}
{{- $taxonomy_title := default (default $taxonomy_page.Data.Plural (i18n $taxonomy_page.Data.Plural)) $taxonomy_page.Title }}
{{- with $term_pages }} {{- with $term_pages }}
<div class=" taxonomy-{{ $taxonomy }} term-list cstyle {{ $style }} {{ $class }}" title="{{ $taxonomy_page.Title }}"{{ if $color }}{{ printf " style=\"--VARIABLE-TAGS-BG-color: %s;\"" $color | safeHTMLAttr }}{{ end }}> <div class=" taxonomy-{{ $taxonomy }} term-list cstyle {{ $style }} {{ $class }}" title="{{ $taxonomy_title }}"{{ if $color }}{{ printf " style=\"--VARIABLE-TAGS-BG-color: %s;\"" $color | safeHTMLAttr }}{{ end }}>
{{- if $icon }} {{- if $icon }}
<i class="{{ $icon }}"></i> <i class="{{ $icon }}"></i>
{{- end }} {{- end }}

View file

@ -6,15 +6,10 @@
{{- if eq $outputFormat "searchpage" }} {{- if eq $outputFormat "searchpage" }}
{{- $title = T "Search" }} {{- $title = T "Search" }}
{{- else if eq .Kind "taxonomy" }} {{- else if eq .Kind "taxonomy" }}
{{- $title = i18n .Data.Plural }} {{- $title = default (default .Data.Plural (i18n .Data.Plural)) .Title }}
{{- if not $title }}
{{- $title = .Data.Plural }}
{{- end }}
{{- else if eq .Kind "term" }} {{- else if eq .Kind "term" }}
{{- $title = i18n .Data.Singular }} {{- $taxonomy_page := .Site.GetPage .Data.Plural }}
{{- if not $title }} {{- $title = default (default .Data.Singular (i18n .Data.Singular)) $taxonomy_page.Params.SingularTitle }}
{{- $title = .Data.Singular }}
{{- end }}
{{- $title = printf "%s %s %s" (default .Data.Term .Title) (default "::" .Site.Params.titleSeparator) $title }} {{- $title = printf "%s %s %s" (default .Data.Term .Title) (default "::" .Site.Params.titleSeparator) $title }}
{{- end }} {{- end }}
{{- if and $title .Site.Title (not (eq $title .Site.Title)) }} {{- if and $title .Site.Title (not (eq $title .Site.Title)) }}