Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Taxonomy bugfix #895

Merged
merged 7 commits into from
Feb 18, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 1 addition & 10 deletions layouts/_default/content.html
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,7 @@
<h1>{{ .Title }}</h1>
{{ with .Params.description }}<div class="lead">{{ . | markdownify }}</div>{{ end }}
<header class="article-meta">
{{ $context := . }}
{{ if .Site.Params.Taxonomy.taxonomyPageHeader }}
{{ range $index, $taxo := .Site.Params.Taxonomy.taxonomyPageHeader }}
{{ partial "taxonomy_terms_article.html" (dict "context" $context "taxo" $taxo ) }}
{{ end }}
{{ else }}
{{ range $taxo, $taxo_map := .Site.Taxonomies }}
{{ partial "taxonomy_terms_article.html" (dict "context" $context "taxo" $taxo ) }}
{{ end }}
{{ end }}
{{ partial "taxonomy_terms_article_wrapper.html" . }}
{{ if (and (not .Params.hide_readingtime) (.Site.Params.ui.readingtime.enable)) }}
{{ partial "reading-time.html" . }}
{{ end }}
Expand Down
11 changes: 1 addition & 10 deletions layouts/_default/taxonomy.html
Original file line number Diff line number Diff line change
Expand Up @@ -12,16 +12,7 @@ <h1>{{ with .Data.Singular }}{{ . | humanize }}: {{ end }}<span>{{ .Title }}</sp
<h3><a href="{{ $manualLink }}"{{ with .Params.manualLinkTitle }} title="{{ . }}"{{ end }}{{ with .Params.manualLinkTarget }} target="{{ . }}"{{ if eq . "_blank" }} rel="noopener"{{ end }}{{ end }}>{{- .Title -}}</a></h3>
<p>{{ .Description | markdownify }}</p>
<header class="article-meta">
{{ $context := . }}
{{ if .Site.Params.Taxonomy.taxonomyPageHeader }}
{{ range $index, $taxo := .Site.Params.Taxonomy.taxonomyPageHeader }}
{{ partial "taxonomy_terms_article.html" (dict "context" $context "taxo" $taxo ) }}
{{ end }}
{{ else }}
{{ range $taxo, $taxo_map := .Site.Taxonomies }}
{{ partial "taxonomy_terms_article.html" (dict "context" $context "taxo" $taxo ) }}
{{ end }}
{{ end }}
{{ partial "taxonomy_terms_article_wrapper.html" . }}
{{ if (and (not .Params.hide_readingtime) (.Site.Params.ui.readingtime.enable)) }}
{{ partial "reading-time.html" . }}
{{ end }}
Expand Down
11 changes: 1 addition & 10 deletions layouts/blog/content.html
Original file line number Diff line number Diff line change
Expand Up @@ -6,16 +6,7 @@ <h1>{{ .Title }}</h1>
<time datetime="{{ $.Date.Format "2006-01-02" }}" class="text-muted">{{ $.Date.Format $.Site.Params.time_format_blog }}</time>
</div>
<header class="article-meta">
{{ $context := . }}
{{ if .Site.Params.Taxonomy.taxonomyPageHeader }}
{{ range $index, $taxo := .Site.Params.Taxonomy.taxonomyPageHeader }}
{{ partial "taxonomy_terms_article.html" (dict "context" $context "taxo" $taxo ) }}
{{ end }}
{{ else }}
{{ range $taxo, $taxo_map := .Site.Taxonomies }}
{{ partial "taxonomy_terms_article.html" (dict "context" $context "taxo" $taxo ) }}
{{ end }}
{{ end }}
{{ partial "taxonomy_terms_article_wrapper.html" . }}
{{ if (and (not .Params.hide_readingtime) (.Site.Params.ui.readingtime.enable)) }}
{{ partial "reading-time.html" . }}
{{ end }}
Expand Down
11 changes: 1 addition & 10 deletions layouts/blog/list.html
Original file line number Diff line number Diff line change
Expand Up @@ -18,16 +18,7 @@ <h2>{{ T "post_posts_in" }} {{ .Key }}</h2>
<h5 class="mt-0 mb-1"><a href="{{ .RelPermalink }}">{{ .Title }}</a></h5>
<p class="mb-2 mb-md-3"><small class="text-muted">{{ .Date.Format ($.Param "time_format_blog") }} {{ T "ui_in"}} {{ .CurrentSection.LinkTitle }}</small></p>
<header class="article-meta">
{{ $context := . }}
{{ if .Site.Params.Taxonomy.taxonomyPageHeader }}
{{ range $index, $taxo := .Site.Params.Taxonomy.taxonomyPageHeader }}
{{ partial "taxonomy_terms_article.html" (dict "context" $context "taxo" $taxo ) }}
{{ end }}
{{ else }}
{{ range $taxo, $taxo_map := .Site.Taxonomies }}
{{ partial "taxonomy_terms_article.html" (dict "context" $context "taxo" $taxo ) }}
{{ end }}
{{ end }}
{{ partial "taxonomy_terms_article_wrapper.html" . }}
{{ if (and (not .Params.hide_readingtime) (.Site.Params.ui.readingtime.enable)) }}
{{ partial "reading-time.html" . }}
{{ end }}
Expand Down
11 changes: 1 addition & 10 deletions layouts/docs/list.html
Original file line number Diff line number Diff line change
Expand Up @@ -3,16 +3,7 @@
<h1>{{ .Title }}</h1>
{{ with .Params.description }}<div class="lead">{{ . | markdownify }}</div>{{ end }}
<header class="article-meta">
{{ $context := . }}
{{ if .Site.Params.Taxonomy.taxonomyPageHeader }}
{{ range $index, $taxo := .Site.Params.Taxonomy.taxonomyPageHeader }}
{{ partial "taxonomy_terms_article.html" (dict "context" $context "taxo" $taxo ) }}
{{ end }}
{{ else }}
{{ range $taxo, $taxo_map := .Site.Taxonomies }}
{{ partial "taxonomy_terms_article.html" (dict "context" $context "taxo" $taxo ) }}
{{ end }}
{{ end }}
{{ partial "taxonomy_terms_article_wrapper.html" . }}
{{ if (and (not .Params.hide_readingtime) (.Site.Params.ui.readingtime.enable)) }}
{{ partial "reading-time.html" . }}
{{ end }}
Expand Down
4 changes: 2 additions & 2 deletions layouts/partials/taxonomy_terms_article.html
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{{ $context := .context }}
{{ $taxo := .taxo }}
{{ $context := .context }}
{{ $taxo := .taxo }}
{{ if (gt (len ($context.GetTerms $taxo)) 0)}}
<div class="taxonomy taxonomy-terms-article taxo-{{ urlize $taxo }}">
<h5 class="taxonomy-title">{{ humanize $taxo }}:</h5>
Expand Down
10 changes: 10 additions & 0 deletions layouts/partials/taxonomy_terms_article_wrapper.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{{ $context := . }}
{{ if isset .Site.Params.Taxonomy "taxonomypageheader" }}
{{ range $index, $taxo := .Site.Params.Taxonomy.taxonomyPageHeader }}
{{ partial "taxonomy_terms_article.html" (dict "context" $context "taxo" $taxo) }}
{{ end }}
{{ else }}
{{ range $taxo, $taxo_map := .Site.Taxonomies }}
{{ partial "taxonomy_terms_article.html" (dict "context" $context "taxo" $taxo) }}
{{ end }}
{{ end }}
10 changes: 5 additions & 5 deletions layouts/partials/taxonomy_terms_cloud.html
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
{{ $context := .context }}
{{ $taxo := .taxo }}
{{ $title := .title }}
{{ if isset $context.Site.Taxonomies ( lower $taxo ) }}
{{ $taxonomy := index $context.Site.Taxonomies ( lower $taxo ) }}
{{ $context := .context }}
{{ $taxo := .taxo }}
{{ $title := .title }}
{{ if isset $context.Site.Taxonomies (lower $taxo) }}
{{ $taxonomy := index $context.Site.Taxonomies (lower $taxo) }}
{{ if (gt (len $taxonomy) 0)}}
<div class="taxonomy taxonomy-terms-cloud taxo-{{ urlize $taxo }}">
{{ with $title }}
Expand Down
10 changes: 5 additions & 5 deletions layouts/partials/taxonomy_terms_clouds.html
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
{{ $context := . }}
{{ if .Site.Params.Taxonomy.taxonomyCloud }}
{{ if isset .Site.Params.Taxonomy "taxonomycloud" }}
{{ range $index, $taxo := .Site.Params.Taxonomy.taxonomyCloud }}
{{ if isset $.Site.Params.Taxonomy "taxonomycloudtitle" }}
{{ $.Scratch.Set "title" ( index $.Site.Params.Taxonomy.taxonomyCloudTitle $index ) }}
{{ $.Scratch.Set "title" (index $.Site.Params.Taxonomy.taxonomyCloudTitle $index) }}
{{ else }}
{{ $.Scratch.Set "title" ( humanize $taxo ) }}
{{ $.Scratch.Set "title" (humanize $taxo) }}
{{ end }}
{{ partial "taxonomy_terms_cloud.html" (dict "context" $context "taxo" $taxo "title" ( $.Scratch.Get "title") ) }}
{{ partial "taxonomy_terms_cloud.html" (dict "context" $context "taxo" $taxo "title" ($.Scratch.Get "title")) }}
{{ end }}
{{ else }}
{{ range $taxo, $taxo_map := .Site.Taxonomies }}
{{ partial "taxonomy_terms_cloud.html" (dict "context" $context "taxo" $taxo "title" ( humanize $taxo ) ) }}
{{ partial "taxonomy_terms_cloud.html" (dict "context" $context "taxo" $taxo "title" (humanize $taxo)) }}
{{ end }}
{{ end }}
11 changes: 1 addition & 10 deletions layouts/swagger/list.html
Original file line number Diff line number Diff line change
Expand Up @@ -3,16 +3,7 @@
<h1>{{ .Title }}</h1>
{{ with .Params.description }}<div class="lead">{{ . | markdownify }}</div>{{ end }}
<header class="article-meta">
{{ $context := . }}
{{ if .Site.Params.Taxonomy.taxonomyPageHeader }}
{{ range $index, $taxo := .Site.Params.Taxonomy.taxonomyPageHeader }}
{{ partial "taxonomy_terms_article.html" (dict "context" $context "taxo" $taxo ) }}
{{ end }}
{{ else }}
{{ range $taxo, $taxo_map := .Site.Taxonomies }}
{{ partial "taxonomy_terms_article.html" (dict "context" $context "taxo" $taxo ) }}
{{ end }}
{{ end }}
{{ partial "taxonomy_terms_article_wrapper.html" . }}
{{ if (and (not .Params.hide_readingtime) (.Site.Params.ui.readingtime.enable)) }}
{{ partial "reading-time.html" . }}
{{ end }}
Expand Down
4 changes: 4 additions & 0 deletions userguide/content/en/docs/Adding content/taxonomy.md
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,10 @@ This will gave you for each in the current page (resp. context) defined taxonomy
</div>
```

### taxonomy_terms_article_wrapper

The partial `taxonomy_terms_article_wrapper` is a wrapper for the partial `taxonomy_terms_article` with the only parameter `context` (most of the time the current page or context `.`) and checks the taxonomy parameters of you projects `config.toml` to loop threw all listed taxonomies in the parameter `taxonomyPageHeader` resp. all defined taxonomies of your page, if `taxonomyPageHeader` isn't set.

### taxonomy_terms_cloud

The partial `taxonomy_terms_cloud` shows all used terms of an given taxonomy (partial parameter `taxo`) for your site (partial parameter `context`, most of the time the current page or context `.`) and with the parameter `title` as headline.
Expand Down