Skip to content

Commit

Permalink
taxonomy: lookup title from overridden taxonomy page #712
Browse files Browse the repository at this point in the history
  • Loading branch information
McShelby committed Nov 3, 2023
1 parent 4ebb6d9 commit 34b8804
Show file tree
Hide file tree
Showing 11 changed files with 39 additions and 65 deletions.
8 changes: 8 additions & 0 deletions exampleSite/content/tags/_index.en.md
@@ -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.
5 changes: 5 additions & 0 deletions exampleSite/content/tags/_index.pir.md
@@ -0,0 +1,5 @@
+++
title = "Tag-a-taggs"
singulartitle = "Tagga"
+++
{{< piratify >}}
11 changes: 3 additions & 8 deletions layouts/_default/index.json
Expand Up @@ -4,15 +4,10 @@
{{- if and .Title .RelPermalink (or (ne (.Scratch.Get "relearnIsHiddenStem") true) (ne .Site.Params.disableSearchHiddenPages true) ) }}
{{- $title := .Title }}
{{- if eq .Kind "taxonomy" }}
{{- $title = i18n .Data.Plural }}
{{- if not $title }}
{{- $title = .Data.Plural }}
{{- end }}
{{- $title = default (default .Data.Plural (i18n .Data.Plural)) .Title }}
{{- else if eq .Kind "term" }}
{{- $title = i18n .Data.Singular }}
{{- if not $title }}
{{- $title = .Data.Singular }}
{{- end }}
{{- $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 .Data.Term .Title) }}
{{- end }}
{{- $pages = $pages | append (dict
Expand Down
11 changes: 3 additions & 8 deletions layouts/_default/index.search.js
Expand Up @@ -4,15 +4,10 @@
{{- if and .Title .RelPermalink (or (ne (.Scratch.Get "relearnIsHiddenStem") true) (ne .Site.Params.disableSearchHiddenPages true) ) }}
{{- $title := .Title }}
{{- if eq .Kind "taxonomy" }}
{{- $title = i18n .Data.Plural }}
{{- if not $title }}
{{- $title = .Data.Plural }}
{{- end }}
{{- $title = default (default .Data.Plural (i18n .Data.Plural)) .Title }}
{{- else if eq .Kind "term" }}
{{- $title = i18n .Data.Singular }}
{{- if not $title }}
{{- $title = .Data.Singular }}
{{- end }}
{{- $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 .Data.Term .Title) }}
{{- end }}
{{- $pages = $pages | append (dict
Expand Down
5 changes: 1 addition & 4 deletions layouts/_default/taxonomy.html
Expand Up @@ -5,10 +5,7 @@
</header>
{{- $page := . }}

{{- $title := i18n .Data.Plural }}
{{- if not $title }}
{{- $title = .Data.Plural }}
{{- end }}
{{- $title := default (default .Data.Plural (i18n .Data.Plural)) .Title }}
<h1 id="{{ $title | plainify | anchorize }}">{{ $title }}</h1>
{{- $lastCapital := "" }}
{{- $terms := slice }}
Expand Down
6 changes: 2 additions & 4 deletions layouts/_default/term.html
Expand Up @@ -5,10 +5,8 @@
</header>
{{- $page := . }}

{{- $title := i18n .Data.Singular }}
{{- if not $title }}
{{- $title = .Data.Singular }}
{{- end }}
{{- $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 .Data.Term .Title) }}
<h1 id="{{ $title | plainify | anchorize }}">{{ $title }}</h1>
{{- .Content }}
Expand Down
11 changes: 3 additions & 8 deletions layouts/partials/breadcrumbs.html
Expand Up @@ -33,15 +33,10 @@
{{- $depth = add $depth 1 }}
{{- $title := $to.Title }}
{{- if eq $to.Kind "taxonomy" }}
{{- $title = i18n $to.Data.Plural }}
{{- if not $title }}
{{- $title = $to.Data.Plural }}
{{- end }}
{{- $title = default (default .Data.Plural (i18n .Data.Plural)) .Title }}
{{- else if eq $to.Kind "term" }}
{{- $title = i18n $to.Data.Singular }}
{{- if not $title }}
{{- $title = $to.Data.Singular }}
{{- end }}
{{- $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 $to.Data.Term $to.Title) }}
{{- end }}
{{- if not $title }}
Expand Down
11 changes: 3 additions & 8 deletions layouts/partials/header.html
Expand Up @@ -14,15 +14,10 @@
{{- if eq $outputFormat "searchpage" }}
{{- $title = T "Search" }}
{{- else if eq .Kind "taxonomy" }}
{{- $title = i18n .Data.Plural }}
{{- if not $title }}
{{- $title = .Data.Plural }}
{{- end }}
{{- $title = default (default .Data.Plural (i18n .Data.Plural)) .Title }}
{{- else if eq .Kind "term" }}
{{- $title = i18n .Data.Singular }}
{{- if not $title }}
{{- $title = .Data.Singular }}
{{- end }}
{{- $taxonomy_page := .Site.GetPage .Data.Plural }}
{{- $title = default (default .Data.Singular (i18n .Data.Singular)) $taxonomy_page.Params.SingularTitle }}
{{- $title = printf "%s %s %s" (default .Data.Term .Title) (default "::" .Site.Params.titleSeparator) $title }}
{{- end }}
{{- if and $title .Site.Title (not (eq $title .Site.Title)) }}
Expand Down
22 changes: 6 additions & 16 deletions layouts/partials/opengraph.html
Expand Up @@ -10,15 +10,10 @@
{{- if eq $outputFormat "searchpage" }}
{{- $title = T "Search" }}
{{- else if eq .Kind "taxonomy" }}
{{- $title = i18n .Data.Plural }}
{{- if not $title }}
{{- $title = .Data.Plural }}
{{- end }}
{{- $title = default (default .Data.Plural (i18n .Data.Plural)) .Title }}
{{- else if eq .Kind "term" }}
{{- $title = i18n .Data.Singular }}
{{- if not $title }}
{{- $title = .Data.Singular }}
{{- end }}
{{- $taxonomy_page := .Site.GetPage .Data.Plural }}
{{- $title = default (default .Data.Singular (i18n .Data.Singular)) $taxonomy_page.Params.SingularTitle }}
{{- $title = printf "%s %s %s" (default .Data.Term .Title) (default "::" .Site.Params.titleSeparator) $title }}
{{- end }}
{{- if and $title .Site.Title (not (eq $title .Site.Title)) }}
Expand Down Expand Up @@ -55,15 +50,10 @@
{{- if eq $outputFormat "searchpage" }}
{{- $title = T "Search" }}
{{- else if eq .Kind "taxonomy" }}
{{- $title = i18n .Data.Plural }}
{{- if not $title }}
{{- $title = .Data.Plural }}
{{- end }}
{{- $title = default (default .Data.Plural (i18n .Data.Plural)) .Title }}
{{- else if eq .Kind "term" }}
{{- $title = i18n .Data.Singular }}
{{- if not $title }}
{{- $title = .Data.Singular }}
{{- end }}
{{- $taxonomy_page := .Site.GetPage .Data.Plural }}
{{- $title = default (default .Data.Singular (i18n .Data.Singular)) $taxonomy_page.Params.SingularTitle }}
{{- $title = printf "%s %s %s" (default .Data.Term .Title) (default "::" .Site.Params.titleSeparator) $title }}
{{- end }}
{{- if and $title .Site.Title (not (eq $title .Site.Title)) }}
Expand Down
3 changes: 2 additions & 1 deletion layouts/partials/term-list.html
Expand Up @@ -29,8 +29,9 @@
{{- end }}
{{- end }}
{{- end }}
{{- $taxonomy_title := default (default $taxonomy_page.Data.Plural (i18n $taxonomy_page.Data.Plural)) $taxonomy_page.Title }}
{{- 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 }}
<i class="{{ $icon }}"></i>
{{- end }}
Expand Down
11 changes: 3 additions & 8 deletions layouts/partials/twitter_cards.html
Expand Up @@ -6,15 +6,10 @@
{{- if eq $outputFormat "searchpage" }}
{{- $title = T "Search" }}
{{- else if eq .Kind "taxonomy" }}
{{- $title = i18n .Data.Plural }}
{{- if not $title }}
{{- $title = .Data.Plural }}
{{- end }}
{{- $title = default (default .Data.Plural (i18n .Data.Plural)) .Title }}
{{- else if eq .Kind "term" }}
{{- $title = i18n .Data.Singular }}
{{- if not $title }}
{{- $title = .Data.Singular }}
{{- end }}
{{- $taxonomy_page := .Site.GetPage .Data.Plural }}
{{- $title = default (default .Data.Singular (i18n .Data.Singular)) $taxonomy_page.Params.SingularTitle }}
{{- $title = printf "%s %s %s" (default .Data.Term .Title) (default "::" .Site.Params.titleSeparator) $title }}
{{- end }}
{{- if and $title .Site.Title (not (eq $title .Site.Title)) }}
Expand Down

0 comments on commit 34b8804

Please sign in to comment.