bunteshaus.de/themes/buha/layouts/partials/layout/gen_list.html

86 lines
2.3 KiB
HTML

{{ $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 or .content (and (.paginate) (.content) (eq $paginator.PageNumber 1)) }}
{{ partial "snippets/content" (dict "content" .context.Content) }}
{{ end }}
{{ if $p }}
<div class="gen_list">
{{ if .title }}<h2>{{ .title }}</h2>{{ end }}
{{ range $p }}
{{ $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>
<h3>
{{ .Title }}
</h3>
{{ with .Resources.GetMatch $banner }}
{{ if eq hugo.Environment "development" }}
Width: {{ .Width }}px<br>
Height: {{ .Height }}px<br>
{{ $ratio := div (float .Width) (float .Height) }}
Ratio: {{ $ratio }}<br>
{{ if lt $ratio "2.608695652173913" }}
not a good ratio<br>
{{ else if gt $ratio "2.608695652173913" }}
{{ end }}
{{ if lt (int .Height) "460" }}
to small, better 800px in height<br>
{{ else if gt (int .Height) "460" }}
to big, better 460px in height<br>
{{ end }}
{{ if lt (int .Width) "1200" }}
to small, better 1200px in width<br>
{{ else if gt (int .Width) "1200" }}
to big, better 1200px in width<br>
{{ end }}
{{ end }}
<div class="img" style="background-image: url({{ .Permalink }})">
</div>
{{ end }}
{{ if .Description }}
{{ .Description }}
{{ else if .Summary }}
<p>{{ .Summary }}</p>
{{ else if .Content }}
{{ .Content }}
{{ else if $image }}
{{ $i := (.Resources.GetMatch $image).Permalink }}
<div class="img-only" style="background-image: url({{ $i }})">
</div>
{{ end }}
</section>
</a>
{{ end }}
{{ if .paginate }}
{{ partial "snippets/paginator" (dict "paginator" $paginator) }}
{{ end }}
</div>
{{ end }}