Sidbare-Elemente in widget-Partials ausgelagert

This commit is contained in:
Marco Galster 2022-11-23 00:41:16 +01:00
parent ca19ee452b
commit 9827bb7ba7
15 changed files with 151 additions and 120 deletions

View file

@ -23,10 +23,9 @@
{{/* Der Paginator wurde in den If-Blöcken zwar erstellt, aber die Variable ist auserhalb nicht sichtbar, daher hier explizit holen.
Dieser kann nach dem ersten erstellen auch nicht mehr verändert werden */}}
{{ $pag := .Paginator }}
<h1>{{ .Title }}</h1>
{{ range $pag.Pages }}
<article class="blog-post">
<h2 class="blog-post-title mb-1"><a href="{{ .RelPermalink }}">{{ .Title }}</a></h2>
<h3 class="blog-post-title_ mb-1"><a href="{{ .RelPermalink }}">{{ .Title }}</a></h3>
<p class="blog-post-meta">{{ partial "metadata.html" . }}</p>
<p>{{ .Summary }}</p>
</article>
@ -36,52 +35,27 @@
{{ end }}
{{ define "sidebar" }}
<div class="position-sticky blog-sidebar" style="top: 2rem;">
<div class="p-4">
{{ $catIdent := .Site.Params.Blog.Categories | default "categories" }}
{{ $cats := (index $.Site.Taxonomies $catIdent)}}
{{ if $cats }}
<h4 class="fst-italic border-bottom border-dark mt-2">Kategorien</h4>
<div class="categories mb-2 d-inline-block">
{{ $parentLink := ($.Site.GetPage (printf "/categories")).Permalink }}
{{ range $key, $sites := $cats }}
<div class="m-1 d-inline-flex">
<a class="bg-dark text-white py-1 px-2 m-0 rounded-start" href="{{ (printf "%s%s" $parentLink $key) }}">{{ $key }}</a>
<div class="bg-danger text-white py-1 px-2 m-0 rounded-end">{{ $sites.Count }}</div>
</div>
{{ end }}
</div>
{{ end }}
<div class="position-sticky" style="top: 0.5rem;">
{{ $catIdent := .Site.Params.Blog.Categories | default "categories" }}
{{ $cats := (index $.Site.Taxonomies $catIdent)}}
{{ if $cats }}
{{- partial "widget/header.html" (dict "title" "Kategorien") -}}
{{- partial "widget/taglist.html" (dict "ident" $catIdent "tax" $cats) -}}
{{ end }}
{{/* https://mertbakir.gitlab.io/hugo/tag-cloud-in-hugo/ */}}
{{ $tagsIdent := .Site.Params.Blog.Tags | default "tags" }}
{{ $tags := (index $.Site.Taxonomies $tagsIdent)}}
{{ if $tags }}
<h4 class="fst-italic border-bottom border-dark mt-2">Schlagwortwolke</h4>
<div class="tag-cloud d-inline-block m-0 p-0">
{{ $parentLink := ($.Site.GetPage (printf "/%s" $tagsIdent)).Permalink }}
{{ $maxCnt := mul 1.0 (index $tags.ByCount 0).Count }}
{{ $minCnt := mul 1.0 (index $tags.ByCount.Reverse 0).Count }}
{{ $div := math.Max 1 (sub $maxCnt $minCnt) }}
{{ range $key, $sites := $tags }}
<!-- add (mul (math.Pow (div $sites.Count $maxCnt) 2.0) 14.0) 8.0 px -->
{{- (printf `<a class="tag-cloud-link m-1 p-1" style="font-size: %.3frem;" href="%s" aria-label="%s %d Einträge">%s<sup>%d</sup></a>`
(add (mul (math.Pow (div (sub $sites.Count $minCnt) $div) 2.0) 0.6) 0.8)
($key | relURL) $key $sites.Count $key $sites.Count
) | safeHTML -}}
<!--<span class="badge">{{ $sites.Count }}</span>-->
{{ end }}
</div>
{{ end }}
{{ $tagsIdent := .Site.Params.Blog.Tags | default "tags" }}
{{ $tags := (index $.Site.Taxonomies $tagsIdent)}}
{{ if $tags }}
{{- partial "widget/header.html" (dict "title" "Schlagwortwolke") -}}
{{- partial "widget/cloud.html" (dict "ident" $tagsIdent "tax" $tags) -}}
{{ end }}
<h4 class="fst-italic border-bottom border-dark mt-2">Archive</h4>
<div class="mb-2 list-group">
{{/* Hier explizit auf Type achten!! */}}
{{ range (where .Site.RegularPages "Type" "blog").GroupByDate "2006" }}
<a class="list-group-item list-group-item-action" href="/blog/{{ .Key }}">Jahr {{ .Key }}</a>
{{ end }}
</div>
{{- partial "widget/header.html" (dict "title" "Archive") -}}
<div class="mb-2 list-group">
{{/* Hier explizit auf Type achten!! */}}
{{ range (where .Site.RegularPages "Type" "blog").GroupByDate "2006" }}
<a class="list-group-item list-group-item-action" href="/blog/{{ .Key }}">Jahr {{ .Key }}</a>
{{ end }}
</div>
</div>
{{ end }}