bunteshaus.de/themes/buha/layouts/partials/layout/gen_list.html
2022-06-12 18:34:24 +02:00

97 lines
2.8 KiB
HTML

{{ $title := .title }}
{{ $p := .pages }}
{{ if and (.limit) (not .paginate) }}
{{ $p = first .limit .pages }}
{{ end }}
{{ $paginator := .pages }}
{{ if .paginate }}
{{ $paginator = .context.Paginate $p }}
{{ $p = $paginator.Pages }}
{{ end }}
{{ if $p }}
<div class="gen_list">
{{ if $title }}<h2>{{ $title }}</h2>{{ end }}
{{ range $p }}
<div class="list_item">
{{ $banner := slice }}
{{ $image := slice }}
{{ $images := slice }}
{{ if .Resources.GetMatch "banner*" }}
{{ $banner = slice (.Resources.GetMatch "banner*") }}
{{ end }}
{{ if .Resources.ByType "image" }}
{{ $image = .Resources.ByType "image" }}
{{ end }}
{{ $images = complement $banner $image }}
{{ $image = (index (complement $banner $image) 0) }}
{{ $banner = (index $banner 0) }}
<a href="{{ .Permalink }}">
<section>
{{ if $title }}<h3>{{ else }}<h2>{{ end }}
{{ .Title }}
{{ if $title }}</h3>{{ else }}</h2>{{ end }}
{{ with .Resources.GetMatch $banner }}
{{ $good_w := "1920"}}
{{ $good_h := "550"}}
{{ $b := true }}
{{ if lt (int .Width) $good_w }}
{{ $b = false }}
{{ if eq hugo.Environment "development" }}
Width: {{ .Width }}px: too small, better {{ $good_w -}}px in width<br>
{{ end }}
{{ else if gt (int .Width) $good_w }}
{{ $b = false }}
{{ if eq hugo.Environment "development" }}
Width: {{ .Width }}px: too big, better {{ $good_w -}}px in width<br>
{{ end }}
{{ end }}
{{ if lt (int .Height) $good_h }}
{{ $b = false }}
{{ if eq hugo.Environment "development" }}
Height: {{ .Height }}px: too small, better {{ $good_h -}}px in height<br>
{{ end }}
{{ else if gt (int .Height) $good_h }}
{{ $b = false }}
{{ if eq hugo.Environment "development" }}
Height: {{ .Height }}px: too big, better {{ $good_h -}}px in height<br>
{{ end }}
{{ end }}
<!--<div class="img" style="background-image: url({{ .Permalink }})">
</div>-->
{{ if eq $b true }}
<img src="{{ .Permalink }}" />
{{ end }}
{{ end }}
<div class="text">
{{ if .Description }}
<p>{{ .Description }}</p>
{{ else if .Summary }}
{{ if hasPrefix .Summary "<p>" }}
{{ .Summary }}
{{ else }}
<p>{{ .Summary }} </p>
{{ end }}
{{ else if .Content }}
<p>{{ .Content }}</p>
{{ else if $image }}
{{ $i := (.Resources.GetMatch $image).Permalink }}
<div class="img-only" style="background-image: url({{ $i }})">
</div>
{{ end }}
</div>
</section>
</a>
</div>
{{ end }}
{{ if .paginate }}
{{ partial "snippets/paginator" (dict "paginator" $paginator) }}
{{ end }}
</div>
{{ end }}