forked from Bunteshaus/bunteshaus.de
169 lines
5.4 KiB
HTML
169 lines
5.4 KiB
HTML
{{- define "title" -}}
|
|
{{- $name := .Name -}}
|
|
{{- if lower $name | i18n -}}
|
|
{{- $name = lower $name | i18n -}}
|
|
{{- end -}}
|
|
{{- $name | humanize -}}
|
|
{{- end -}}
|
|
|
|
{{- define "main" -}}
|
|
{{- $paginator := slice -}}
|
|
{{- if eq .Section "events" -}}
|
|
{{- $paginator = .Paginate (where site.RegularPages.ByLastmod.Reverse ".Params.when" "ne" nil) -}}
|
|
{{- else if eq .Section "news" }}
|
|
{{- $paginator = .Paginate (where (where .Site.RegularPages.ByLastmod.Reverse "Permalink" "!=" .Permalink) "Type" "in" .Site.Params.mainSections) }}
|
|
{{- else -}}
|
|
{{- $paginator = .Paginate .RegularPagesRecursive.ByLastmod.Reverse -}}
|
|
{{- end -}}
|
|
{{- range first 5 $paginator.Pages -}}
|
|
<article>
|
|
<a href="{{- .Permalink -}}">
|
|
<h2>{{ if and (isset .Params "categories") (eq .Section "events") }}{{ index .Params.categories 0 }}: {{ end }}{{- .Title -}}</h2>
|
|
{{ if .Params.when }}
|
|
<div style="margin-bottom: .4em;"><b>{{ .Params.when }}</b></div>
|
|
{{ end }}
|
|
{{ if ne .Params.price nil }}
|
|
{{ if eq .Params.price "free" }}
|
|
<div style="margin-bottom: .4em;">Der Eintritt ist frei.</div>
|
|
{{ else }}
|
|
<div style="margin-bottom: .4em;">Eintritt: {{ .Params.price }}</div>
|
|
{{ end }}
|
|
{{ end }}
|
|
{{ if ne .Params.register nil }}
|
|
<div>Anmeldung unter {{ .Params.register }} erwünscht</div>
|
|
{{ end }}
|
|
{{ if ne .Params.covid nil }}
|
|
<div>Es gilt die {{ .Params.covid }} Regel</div>
|
|
{{ end }}
|
|
<div id="articledata">
|
|
{{- if ne .Section .Site.Params.hiddenfolder -}}
|
|
{{- if .Resources.ByType "image" -}}
|
|
<div id="articleimage">
|
|
{{- $pic := index (.Resources.ByType "image") 0 -}}
|
|
{{- $thumb := $pic.Resize "1024x" }}
|
|
<img src="{{- $thumb.Permalink -}}"/>
|
|
</div>
|
|
{{- end }}
|
|
<div id="articletext">
|
|
{{- if .Params.description -}}
|
|
{{- .Params.description | plainify -}}
|
|
{{- else -}}
|
|
{{- .Summary | plainify -}}
|
|
{{- end }}
|
|
{{ if .Truncated }}
|
|
<div id="readmore">{{- i18n "readmore" -}}..</div>
|
|
{{ end }}
|
|
</div>
|
|
</div>
|
|
{{- end -}}
|
|
</a>
|
|
</article>
|
|
{{- 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 -}}
|
|
|
|
|
|
|