bunteshaus.de/themes/buha/layouts/_default/list.html

198 lines
6.0 KiB
HTML
Raw Normal View History

2021-10-23 22:20:01 +02:00
{{- define "title" -}}
2022-03-27 15:10:18 +02:00
{{ $name := .Name | lower }}
2022-03-27 14:24:21 +02:00
{{ if ne ($name | i18n) "" }}
{{ $name = $name | i18n }}
2022-03-27 15:10:18 +02:00
{{ else }}
{{ if ne .Section "events" }}
{{ $name = $name | singularize }}
{{ end }}
{{ $name = $name | humanize }}
2022-03-27 14:24:21 +02:00
{{ end }}
{{ $name }}
2021-10-23 22:20:01 +02:00
{{- end -}}
{{- define "main" -}}
2022-03-27 14:24:21 +02:00
{{ $s := .Site.Params }}
2022-03-27 16:47:39 +02:00
2021-10-23 22:20:01 +02:00
{{- $paginator := slice -}}
2022-03-27 14:24:21 +02:00
{{- $posts := where .Site.RegularPages "Type" "in" $s.mainSections }}
2022-03-27 16:47:39 +02:00
{{ $meta := "false" }}
2021-10-23 22:20:01 +02:00
{{- if eq .Section "events" -}}
2022-03-28 12:56:55 +02:00
{{- $paginator = .Paginate (where site.RegularPages.ByDate.Reverse ".Params.when" "ne" nil) -}}
2021-10-23 22:20:01 +02:00
{{- else if eq .Section "news" }}
2022-03-28 12:56:55 +02:00
{{- $paginator = .Paginate (where (where .Site.RegularPages.ByDate.Reverse "Permalink" "!=" .Permalink) "Type" "in" .Site.Params.mainSections) }}
2022-03-27 14:24:21 +02:00
{{- else if eq .Section "featured" }}
{{- $paginator = .Paginate (where $posts "Params.featured" true) -}}
{{- else if eq .Section "recurrent" }}
{{- $paginator = .Paginate (where .Site.RegularPages "Params.recurrent" true) -}}
2021-10-23 22:20:01 +02:00
{{- else -}}
2022-03-28 12:56:55 +02:00
{{- $paginator = .Paginate .RegularPagesRecursive.ByDate.Reverse -}}
2021-10-23 22:20:01 +02:00
{{- end -}}
2022-03-27 16:47:39 +02:00
{{ if eq $paginator.PageNumber 1 }}
{{ if ne .Content "" }}
<article>
{{ .Content }}
</article>
{{ end }}
{{ end }}
2021-10-23 22:20:01 +02:00
{{- range first 5 $paginator.Pages -}}
2022-03-27 00:05:47 +01:00
<article class="articlebgcol1 borderrad25"><a href="{{- .Permalink -}}">
<div id="articletitle">
<h2>{{- .Title -}}</h2>
</div>
<div id="articlecontent">
<div id="articlemeta">
{{ if and (ne .Params.when "") (ne .Params.when nil) }}
<div style="margin-bottom: .4em;"><b>{{ .Params.when }}</b></div>
2022-03-27 16:47:39 +02:00
{{ $meta = "true" }}
2022-03-27 00:05:47 +01:00
{{ end }}
{{ if and (ne .Params.price "") (ne .Params.price nil) }}
{{ if eq .Params.price "free" }}
<div style="margin-bottom: .4em;">Der Eintritt ist frei.</div>
2022-03-27 16:47:39 +02:00
{{ $meta = "true" }}
2022-03-27 00:05:47 +01:00
{{ else }}
<div style="margin-bottom: .4em;">Eintritt: {{ .Params.price }}</div>
2022-03-27 16:47:39 +02:00
{{ $meta = "true" }}
2021-10-23 22:20:01 +02:00
{{ end }}
2022-03-27 00:05:47 +01:00
{{ end }}
</div>
<div id="articleinner">
<div id="articledata">
2022-03-27 03:54:23 +02:00
{{- if .Resources.ByType "image" -}}
{{- $pic := index (.Resources.ByType "image") 0 -}}
{{ $thumb := "" }}
{{ if eq .Content "" }}
<div class="notext">
{{- $thumb = $pic.Resize "1024x" }}
{{ else }}
<div class="text">
{{- $thumb = $pic.Resize "2048x" }}
{{ end }}
<img src="{{- $thumb.Permalink -}}"/>
</div>
{{- end }}
2022-03-27 00:05:47 +01:00
<div id="articletext">
2022-03-27 03:54:23 +02:00
{{- if .Params.description -}}
{{- .Params.description -}}
{{- else -}}
{{- .Summary -}}
{{- end }}
2022-03-27 16:47:39 +02:00
{{ if or .Truncated (eq $meta "true") }}
2022-03-27 03:54:23 +02:00
<div id="readmore">{{- i18n "readmore" -}}..</div>
{{ end }}
2022-03-27 00:05:47 +01:00
</div>
</div>
</div>
</div>
</a></article>
2021-10-23 22:20:01 +02:00
{{- end }}
<div id="pagination">
<!-- Number of links either side of the current page. -->
{{ $adjacent_links := 2 }}
<!-- $max_links = ($adjacent_links * 2) + 1 -->
{{ $max_links := (add (mul $adjacent_links 2) 1) }}
<!-- $lower_limit = $adjacent_links + 1 -->
{{ $lower_limit := (add $adjacent_links 1) }}
<!-- $upper_limit = $paginator.TotalPages - $adjacent_links -->
{{ $upper_limit := (sub $paginator.TotalPages $adjacent_links) }}
<!-- If there's more than one page. -->
{{ if gt $paginator.TotalPages 1 }}
<!-- First page. -->
{{ if ne $paginator.PageNumber 1 }}
<a class="pagination__link pagination__link--first" href="{{ $paginator.First.URL }}">
««
</a>
{{ end }}
<!-- Previous page. -->
{{ if $paginator.HasPrev }}
<a href="{{ $paginator.Prev.URL }}" class="pagination__link pagination__link--previous">
«
</a>
{{ end }}
<!-- Page numbers. -->
{{ range $paginator.Pagers }}
{{ $.Scratch.Set "page_number_flag" false }}
<!-- Advanced page numbers. -->
{{ if gt $paginator.TotalPages $max_links }}
<!-- Lower limit pages. -->
<!-- If the user is on a page which is in the lower limit. -->
{{ if le $paginator.PageNumber $lower_limit }}
<!-- If the current loop page is less than max_links. -->
{{ if le .PageNumber $max_links }}
{{ $.Scratch.Set "page_number_flag" true }}
{{ end }}
<!-- Upper limit pages. -->
<!-- If the user is on a page which is in the upper limit. -->
{{ else if ge $paginator.PageNumber $upper_limit }}
<!-- If the current loop page is greater than total pages minus $max_links -->
{{ if gt .PageNumber (sub $paginator.TotalPages $max_links) }}
{{ $.Scratch.Set "page_number_flag" true }}
{{ end }}
<!-- Middle pages. -->
{{ else }}
{{ if and ( ge .PageNumber (sub $paginator.PageNumber $adjacent_links) ) ( le .PageNumber (add $paginator.PageNumber $adjacent_links) ) }}
{{ $.Scratch.Set "page_number_flag" true }}
{{ end }}
{{ end }}
<!-- Simple page numbers. -->
{{ else }}
{{ $.Scratch.Set "page_number_flag" true }}
{{ end }}
<!-- Output page numbers. -->
{{ if eq ($.Scratch.Get "page_number_flag") true }}
<a href="{{ .URL }}" class="pagination__link">
{{ .PageNumber }}
</a>
{{ end }}
{{ end }}
<!-- Next page. -->
{{ if $paginator.HasNext }}
<a href="{{ $paginator.Next.URL }}" class="pagination__link pagination__link--next">
»
</a>
{{ end }}
<!-- Last page. -->
{{ if ne $paginator.PageNumber $paginator.TotalPages }}
<a class="pagination__link pagination__link--last" href="{{ $paginator.Last.URL }}">
»»
</a>
{{ end }}
{{ end }}
</div>
{{- end -}}
2022-03-26 20:28:14 +01:00
{{ define "sidebar" }}
{{- partial "sidebar" . }}
{{ end }}