blogamore/layouts/blog/list.html

87 lines
4 KiB
HTML
Raw Normal View History

2022-11-13 20:52:45 +01:00
{{ define "head" }}
{{ if eq .Type "blog" }}
{{ $latestEntry := index (where (where .Site.RegularPages "Type" "blog") "Params.featured" true).ByPublishDate.Reverse 0 }}
2022-11-20 15:04:48 +01:00
<div class="p-4 m-2 rounded text-bg-dark">
2022-11-13 20:52:45 +01:00
<div class="col-md6 px-0">
<h1 class="display-4 fst-italic">{{ $latestEntry.Title }}</h1>
2022-11-15 23:34:16 +01:00
<p class="lead my-3">{{ $latestEntry.Summary | safeHTML }}</p>
2022-11-13 20:52:45 +01:00
<p class="lead mb-0"><a href="{{ $latestEntry.Permalink }}" class="text-white fw-bold">Weiter lesen...</a></p>
</div>
</div>
{{ end }}
{{ end }}
{{ define "main" }}
{{/* Paginator initialisieren, in der Reihenfolge die man sich im Blog wünscht */}}
{{ if eq .Type "blog" }}
{{/* Der 1te Weg soll alle Blog-Einträge finden*/}}
2022-11-15 23:34:16 +01:00
{{ $pag := .Paginate (where .Site.RegularPages "Type" "blog").ByPublishDate.Reverse }}
2022-11-13 20:52:45 +01:00
{{ else }}
{{/* Der 2te Weg ist über die Archive-Gruppierung, und dort wird nicht paginiert */}}
{{ $pag := .Paginate .Pages.ByPublishDate.Reverse 9999 }}
{{ end }}
{{/* 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>
<p class="blog-post-meta">{{ partial "metadata.html" . }}</p>
<p>{{ .Summary }}</p>
</article>
{{ end }}
{{ template "partials/pagination.html" . }}
{{ 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 }}
2022-11-20 15:04:48 +01:00
<h4 class="fst-italic border-bottom border-dark mt-2">Kategorien</h4>
<div class="categories mb-2 d-inline-block">
2022-11-13 20:52:45 +01:00
{{ $parentLink := ($.Site.GetPage (printf "/categories")).Permalink }}
{{ range $key, $sites := $cats }}
2022-11-20 15:04:48 +01:00
<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>
2022-11-13 20:52:45 +01:00
{{ end }}
2022-11-20 15:04:48 +01:00
</div>
2022-11-13 20:52:45 +01:00
{{ end }}
{{/* https://mertbakir.gitlab.io/hugo/tag-cloud-in-hugo/ */}}
{{ $tagsIdent := .Site.Params.Blog.Tags | default "tags" }}
{{ $tags := (index $.Site.Taxonomies $tagsIdent)}}
{{ if $tags }}
2022-11-20 15:04:48 +01:00
<h4 class="fst-italic border-bottom border-dark mt-2">Schlagwortwolke</h4>
<div class="tag-cloud d-inline-block m-0 p-0">
2022-11-13 20:52:45 +01:00
{{ $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 -->
2022-11-20 15:04:48 +01:00
{{- (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>`
2022-11-15 23:34:16 +01:00
(add (mul (math.Pow (div (sub $sites.Count $minCnt) $div) 2.0) 0.6) 0.8)
2022-11-20 15:04:48 +01:00
($key | relURL) $key $sites.Count $key $sites.Count
2022-11-15 23:34:16 +01:00
) | safeHTML -}}
2022-11-13 20:52:45 +01:00
<!--<span class="badge">{{ $sites.Count }}</span>-->
{{ end }}
</div>
{{ end }}
2022-11-20 15:04:48 +01:00
<h4 class="fst-italic border-bottom border-dark mt-2">Archive</h4>
<div class="mb-2 list-group">
2022-11-13 20:52:45 +01:00
{{/* Hier explizit auf Type achten!! */}}
{{ range (where .Site.RegularPages "Type" "blog").GroupByDate "2006" }}
2022-11-20 15:04:48 +01:00
<a class="list-group-item list-group-item-action" href="/blog/{{ .Key }}">Jahr {{ .Key }}</a>
2022-11-13 20:52:45 +01:00
{{ end }}
2022-11-20 15:04:48 +01:00
</div>
2022-11-13 20:52:45 +01:00
</div>
</div>
{{ end }}