gcg-website/layouts/partials/blog-sidebar.html
Denys Konovalov e289db2fa0
All checks were successful
website-main / prod-build (push) Successful in 55s
website-main / test-build (push) Successful in 12s
sort tags by size
2023-11-15 21:45:18 +01:00

50 lines
2.2 KiB
HTML

<aside class="col-lg-4 mt-4 mt-lg-0" data-pagefind-ignore="all">
<div class="mb-4">
<h4 class="mb-4">Kategorien</h4>
{{ $transliterations := .Site.Data.transliterations.transliterations }}
{{ if isset .Site.Taxonomies "categories" }}
{{ if not (eq (len .Site.Taxonomies.categories) 0) }}
<div class="tag-list">
{{ range $name, $items := .Site.Taxonomies.categories }}
<a href="{{ `categories/` | relURL }}{{ $name | urlize | lower }}">{{ if (index $transliterations $name) }}{{ index $transliterations $name }}{{ else }}{{ $name | title }}{{end}}</a>
{{ end }}
</div>
{{ end }}
{{ end }}
</div>
<div class="mb-4">
<h4 class="mb-4"><a href="{{ `tags/` | relURL }}">Tags</a></h4>
{{ if isset .Site.Taxonomies "tags" }}
{{ if not (eq (len .Site.Taxonomies.tags) 0) }}
<div class="tag-list">
{{ $tags := dict }}
{{ range $name, $items := .Site.Taxonomies.tags }}
{{ $tags = merge $tags (dict (print $name) (dict "name" $name "items" $items "len" (len $items))) }}
{{ end }}
{{ range (sort $tags "len" "desc") }}
{{ $pages := sort .items "Params.date" "desc" }}
{{ if or (gt (len $pages) 2) (gt ((index $pages 0).Params.date | time.AsTime).Unix (sub now.Unix 7889229)) }}
{{ $size := "1rem" }}
{{ if gt (len $pages) 3 }}{{ $size = "1.25rem" }}{{ else if lt (len $pages) 2 }}{{ $size = ".75rem" }}{{ end }}
<a href="{{ `tags/` | relURL }}{{ .name | urlize | lower }}" style="font-size: {{ $size }};">{{ .name }}</a>
{{ end }}
{{ end }}
</div>
{{ end }}
{{ end }}
</div>
<div class="bg-white">
<h4 class="mb-4">Neuste Beiträge</h4>
{{ range first 5 ( where .Site.Pages "Type" "post" )}}
<div class="d-flex border-bottom border-color pb-3 mb-3">
<a href="{{ .Permalink }}"><img class="me-3 post-thumb-sm" src="{{ .Params.image | absURL }}"></a>
<div class="flex-grow-1 min-w-0 d-flex flex-column justify-content-between">
<a href="{{ .Permalink }}">
<h5 class="text-truncate">{{ .Title }}</h5>
</a>
{{ time.Format "02. Jan 2006" .PublishDate }}
</div>
</div>
{{ end }}
</div>
</aside>