Skip to content

Commit

Permalink
fix: move tag generation and lists around
Browse files Browse the repository at this point in the history
see #893

Signed-off-by: Patrick Kollitsch <[email protected]>
  • Loading branch information
davidsneighbour committed May 2, 2024
1 parent cc953bd commit 7c20b83
Show file tree
Hide file tree
Showing 6 changed files with 72 additions and 47 deletions.
3 changes: 2 additions & 1 deletion layouts/_default/taxonomy.html
Original file line number Diff line number Diff line change
Expand Up @@ -22,5 +22,6 @@ <h1 class="post-title">{{ lang.Translate "theme.tags" }}</h1>
</div>
</div>
</section>
{{- partials.Include "content/sections/tagoverview.html" . -}}
{{- $options := dict "type" "list" "context" . -}}
{{- partial "content/components/tags/tags-overview.html" $options -}}
{{- end -}}
3 changes: 2 additions & 1 deletion layouts/_default/term.html
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ <h1 class="post-title">
</div>
</section>
{{- partials.Include "content/sections/posts.html" . -}}
{{- partials.Include "content/sections/tagoverview.html" . -}}
{{- $options := dict "type" "list" "context" . -}}
{{- partial "content/components/tags/tags-overview.html" $options -}}
{{- partials.Include "func/hook.html" ( collections.Dictionary "hook" "container-end" "context" . ) -}}
{{- end -}}
6 changes: 0 additions & 6 deletions layouts/partials/content/components/tags/tag.html

This file was deleted.

80 changes: 66 additions & 14 deletions layouts/partials/content/components/tags/tags-overview.html
Original file line number Diff line number Diff line change
@@ -1,15 +1,67 @@
{{- $current := .Name -}}
<ul class="list-inline">
{{- range $index, $value := (collections.Index site.Taxonomies .Type) -}}
{{- if compare.Gt .Count 1 -}}
<li class="list-inline-item mx-2">
<a href="/tags/{{ $index }}/" class="text-decoration-none">
{{- if compare.Eq $current $index -}}<strong>{{- end -}}
{{- partials.Include "icon.html" "tag-fill" -}}
{{- $index -}} ({{- .Count -}})
{{- if compare.Eq $current $index -}}</strong>{{- end -}}
</a>
</li>
{{- end -}}
{{- $type := "list" -}}
{{- with .type -}}
{{- $type = . -}}
{{- end -}}

{{- $icon := "tag-fill" -}}
{{- with .icon -}}
{{- $icon = . -}}
{{- end -}}

{{- if eq (.type | default "page") "page" -}}
{{- range .tags -}}
{{- partialCached "tags/single-tag.html" . -}}
{{- end -}}
</ul>
{{- else -}}
{{- partialCached "tags/taglist.html" .context -}}
{{- end -}}

{{- define "partials/tags/taglist.html" -}}

{{- $current := page.Name -}}
<div class="container">
<div class="row py-6">
<div class="col text-center">
<ul class="list-inline">
{{- range $index, $value := (collections.Index site.Taxonomies .Type) -}}
{{- if compare.Gt .Count 1 -}}
<li class="list-inline-item mx-2">
<a href="/tags/{{ $index }}/" class="text-decoration-none">
{{- if compare.Eq $current $index -}}<strong>{{- end -}}
{{- partials.Include "icon.html" "tag-fill" -}}
{{- $index -}} ({{- .Count -}})
{{- if compare.Eq $current $index -}}</strong>{{- end -}}
</a>
</li>
{{- end -}}
{{- end -}}
</ul>
</div>
</div>
</div>
{{- end -}}

{{- define "partials/tags/single-tag.html" -}}

<span class="badge">
<a href="{{- .Permalink -}}">
{{- partials.Include "icon.html" "tag-fill" -}}
{{- .Title -}}
{{/* ({{- .Count -}}) */}}
</a>
</span>

<span
class="badge {{ with .Params.class -}}
text-bg-{{ . }}
{{ else }}
text-bg-light
{{ end }} ms-2"
>
{{ with .Params.icon -}}
{{ partials.Include "icon.html" . }}
{{ end }}
<a rel="tag" href="{{- .Permalink -}}">#{{- .Title | strings.ToLower -}}</a>
</span>

{{- end -}}
16 changes: 2 additions & 14 deletions layouts/partials/content/components/tags/tags.html
Original file line number Diff line number Diff line change
@@ -1,18 +1,6 @@
{{- with (.GetTerms "tags") -}}
<div class="is--tags">
{{- range . -}}
<span
class="badge {{ with .Params.class -}}
text-bg-{{ . }}
{{ else }}
text-bg-light
{{ end }} ms-2"
>
{{ with .Params.icon -}}
{{ partials.Include "icon.html" . }}
{{ end }}
<a rel="tag" href="{{- .Permalink -}}">#{{- .Title | strings.ToLower -}}</a>
</span>
{{- end -}}
{{- $options := dict "tags" . "type" "page" "icon" "tag-fill" -}}
{{- partial "content/components/tags/tags-overview.html" $options -}}
</div>
{{- end -}}
11 changes: 0 additions & 11 deletions layouts/partials/content/sections/tagoverview.html

This file was deleted.

0 comments on commit 7c20b83

Please sign in to comment.