Skip to content

Commit

Permalink
taxonomy: print term title even if not set in term frontmatter #701
Browse files Browse the repository at this point in the history
  • Loading branch information
McShelby committed Oct 28, 2023
1 parent 5c71fd8 commit e7ad33d
Show file tree
Hide file tree
Showing 11 changed files with 21 additions and 14 deletions.
4 changes: 4 additions & 0 deletions exampleSite/content/tags/hidden/_index.en.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
+++
+++

This lists all pages that are hidden from the home page. This includes pages that define `hidden=true` in their frontmatter as weill as descendents of hidden pages.
3 changes: 3 additions & 0 deletions exampleSite/content/tags/hidden/_index.pir.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
+++
+++
{{< piratify true >}}
2 changes: 1 addition & 1 deletion layouts/_default/index.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
{{- if not $title }}
{{- $title = .Data.Singular }}
{{- end }}
{{- $title = printf "%s %s %s" $title (default "::" .Site.Params.titleSeparator) .Title }}
{{- $title = printf "%s %s %s" $title (default "::" .Site.Params.titleSeparator) (default .Data.Term .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 @@ -13,7 +13,7 @@
{{- if not $title }}
{{- $title = .Data.Singular }}
{{- end }}
{{- $title = printf "%s %s %s" $title (default "::" .Site.Params.titleSeparator) .Title }}
{{- $title = printf "%s %s %s" $title (default "::" .Site.Params.titleSeparator) (default .Data.Term .Title) }}
{{- end }}
{{- $pages = $pages | append (dict
"uri" (partial "relLangPrettyUglyURL.hugo" (dict "to" .))
Expand Down
4 changes: 2 additions & 2 deletions layouts/_default/taxonomy.html
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
<h1 id="{{ $title | plainify | anchorize }}">{{ $title }}</h1>
{{- $lastCapital := "" }}
{{- range .Data.Terms.Alphabetical }}
{{- $capital := substr .Page.Title 0 1 | upper }}
{{- $capital := substr (default .Page.Data.Term .Page.Title) 0 1 | upper }}
{{- if ne $lastCapital $capital }}
{{- if ne $lastCapital "" }}
</ul>
Expand All @@ -29,7 +29,7 @@ <h2 id="{{ $capital | plainify | anchorize }}">{{ $capital }}</h2>
{{- end }}
{{- end }}
{{- if $len }}
<li><a href="{{ partial "relLangPrettyUglyURL.hugo" (dict "to" .Page) }}">{{ .Page.Title }}</a> ({{ $len }})</li>
<li><a href="{{ partial "relLangPrettyUglyURL.hugo" (dict "to" .Page) }}">{{ (default .Page.Data.Term .Page.Title) }}</a> ({{ $len }})</li>
{{- end }}
{{- $lastCapital = $capital }}
{{- end }}
Expand Down
2 changes: 1 addition & 1 deletion layouts/_default/term.html
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
{{- if not $title }}
{{- $title = .Data.Singular }}
{{- end }}
{{- $title = printf "%s %s %s" $title (default "::" .Site.Params.titleSeparator) .Title }}
{{- $title = printf "%s %s %s" $title (default "::" .Site.Params.titleSeparator) (default .Data.Term .Title) }}
<h1 id="{{ $title | plainify | anchorize }}">{{ $title }}</h1>
{{- .Content }}
<ul class="columnize">
Expand Down
8 changes: 4 additions & 4 deletions layouts/partials/breadcrumbs.html
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
{{- $breadcrumb := slice }}
{{- range seq $depth }}
{{- if $to }}
{{- if $to.Title }}
{{- if (default $to.Data.Term $to.Title) }}
{{- $breadcrumb = $breadcrumb | append $to }}
{{- end }}
{{- else }}
Expand All @@ -32,17 +32,17 @@
{{- $to := $e }}
{{- $depth = add $depth 1 }}
{{- $title := $to.Title }}
{{- if eq .Kind "taxonomy" }}
{{- if eq $to.Kind "taxonomy" }}
{{- $title = i18n $to.Data.Plural }}
{{- if not $title }}
{{- $title = $to.Data.Plural }}
{{- end }}
{{- else if eq .Kind "term" }}
{{- else if eq $to.Kind "term" }}
{{- $title = i18n $to.Data.Singular }}
{{- if not $title }}
{{- $title = $to.Data.Singular }}
{{- end }}
{{- $title = printf "%s %s %s" $title (default "::" .Site.Params.titleSeparator) $to.Title }}
{{- $title = printf "%s %s %s" $title (default "::" .Site.Params.titleSeparator) (default $to.Data.Term $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 @@ -23,7 +23,7 @@
{{- if not $title }}
{{- $title = .Data.Singular }}
{{- end }}
{{- $title = printf "%s %s %s" .Title (default "::" .Site.Params.titleSeparator) $title }}
{{- $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)) }}
{{- $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 @@ -19,7 +19,7 @@
{{- if not $title }}
{{- $title = .Data.Singular }}
{{- end }}
{{- $title = printf "%s %s %s" .Title (default "::" .Site.Params.titleSeparator) $title }}
{{- $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)) }}
{{- $title = printf "%s %s %s" $title (default "::" .Site.Params.titleSeparator) .Site.Title }}
Expand Down Expand Up @@ -64,7 +64,7 @@
{{- if not $title }}
{{- $title = .Data.Singular }}
{{- end }}
{{- $title = printf "%s %s %s" .Title (default "::" .Site.Params.titleSeparator) $title }}
{{- $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)) }}
{{- $title = printf "%s %s %s" $title (default "::" .Site.Params.titleSeparator) .Site.Title }}
Expand Down
2 changes: 1 addition & 1 deletion layouts/partials/term-list.html
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@
<ul>
{{- range $term_page := . }}
{{- $to := . }}
<li><a class="term-link" href="{{ partial "relLangPrettyUglyURL.hugo" (dict "to" $to) }}">{{ $to.Title }}</a></li>
<li><a class="term-link" href="{{ partial "relLangPrettyUglyURL.hugo" (dict "to" $to) }}">{{ default $to.Data.Term $to.Title }}</a></li>
{{- end }}
</ul>
</div>
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 @@ -15,7 +15,7 @@
{{- if not $title }}
{{- $title = .Data.Singular }}
{{- end }}
{{- $title = printf "%s %s %s" .Title (default "::" .Site.Params.titleSeparator) $title }}
{{- $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)) }}
{{- $title = printf "%s %s %s" $title (default "::" .Site.Params.titleSeparator) .Site.Title }}
Expand Down

0 comments on commit e7ad33d

Please sign in to comment.