Intelligent Tags (schließt #204)
All checks were successful
website-main / prod-build (push) Successful in 44s
website-main / test-build (push) Successful in 14s

This commit is contained in:
Denys Konovalov 2023-10-31 20:55:16 +01:00
parent 504cb7b45c
commit da0484c29a
3 changed files with 27 additions and 2 deletions

@ -429,6 +429,8 @@ details[open] summary {
padding: 5px 10px;
background: var(--bs-secondary-bg);
color: var(--bs-secondary-color);
height: fit-content;
width: fit-content;
}
.tag-list a:hover {

@ -0,0 +1,18 @@
{{ define "main" }}
<section class="section" data-pagefind-body>
<div class="container">
<div class="tag-list">
{{ $transliterations := site.Data.transliterations.transliterations }}
{{ range $name, $items := .Data.Terms }}
{{ if eq $.Data.Plural "tags" }}
<a href="{{ `tags/` | relURL }}{{ $name | urlize | lower }}">{{ $name }}</a>
{{ else if eq $.Data.Plural "categories" }}
<a href="{{ `categories/` | relURL }}{{ $name | urlize | lower }}">{{ if (index $transliterations $name) }}{{ index $transliterations $name }}{{ else }}{{ $name | title }}{{end}}</a>
{{ end }}
{{ end }}
</div>
</div>
</section>
{{ end }}

@ -13,12 +13,17 @@
{{ end }}
</div>
<div class="mb-4">
<h4 class="mb-4">Tags</h4>
<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">
{{ range $name, $items := .Site.Taxonomies.tags }}
<a href="{{ `tags/` | relURL }}{{ $name | urlize | lower }}">{{ $name }}</a>
{{ $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 }}