bunteshaus.de/themes/buha/layouts/partials/snippets/gen_list.html
2022-06-23 22:17:04 +02:00

178 lines
6.1 KiB
HTML

{{ $title := .title }}
{{ $link := .link }}
{{ $pages := .pages }}
{{ if and (.limit) (not .paginate) }}
{{ $pages = first .limit .pages }}
{{ end }}
{{ $act_section := .context.Section }}
{{ $paginator := .pages }}
{{ $return_paginator := "" }}
{{ if .paginate }}
{{ $paginator = .context.Paginate $pages }}
{{ $pages = $paginator.Pages }}
{{ $return_paginator := $paginator }}
{{ end }}
{{ $bptiny := "40em" }}
{{ $bpsmall := "48em" }}
{{ $bpmedium := "64em" }}
{{ $bplarge := "85.375em" }}
{{ $bpxlarge := "120em" }}
{{ $bpxxlarge := "160em" }}
{{ if $pages }}
<div class="gen_list">
{{ if $title }}
<h2 style="display: flex; align-items: baseline;">
{{ if $link }}
<a href="{{ $link | relLangURL }}">
{{ end }}
{{ $title }}
{{ if $link }}
</a>
<a href="{{ $link | relLangURL }}" style="text-decoration: underline; font-size: x-small; margin-left: 1em;">({{ if i18n "all" }}{{ i18n "all"}}{{ else }}{{ "all" }}{{ end }})</a>
{{ end }}
</h2>
{{ end }}
{{ range $pages.ByLastmod.Reverse }}
{{ $slug := "" }}
{{ with .File }}
{{ $slug = anchorize .ContentBaseName }}
{{ end }}
<div>
{{ $metas := dict "when" .Params.when "price" .Params.price }}
{{ $banner := slice }}
{{ $image := slice }}
{{ $images := slice }}
{{ $dir := ""}}
{{ with .File }}
{{ $dir = .Dir }}
{{ end }}
{{ 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 }}" class="list_item">
{{ if $title }}<h3>{{ else }}<h2>{{ end }}
{{ if ne $act_section "about" }}
{{ if .Params.events }}
{{ index .Params.events 0 }}:
{{ else if .Params.recurrent }}
{{ if i18n "recurrent"}}
{{ i18n "recurrent"}}:
{{ else }}
{{ "Recurrent"}}:
{{ end }}
{{ else if .Params.categories }}
{{ if in .Params.categories .Site.Params.ownCategory }}
{{ if i18n "own_category" }}{{ i18n "own_category" }}{{ else }}From us{{ end -}}:
{{ end }}
{{ end }}
{{ end }}
{{ .Title }}
{{ if $title }}</h3>{{ else }}</h2>{{ end }}
{{ with .Resources.GetMatch $banner }}
{{ $img := . }}
{{ $good_w := "1920"}}
{{ $good_h := "550"}}
{{ $b := true }}
{{ if or (lt (int .Width) $good_w) (gt (int .Width) $good_w) (lt (int .Height) $good_h) (gt (int .Height) $good_h) }}
<div class="dev left">
{{ if lt (int .Width) $good_w }}
{{ $b = false }}
{{ if eq hugo.Environment "development" }}
Width: {{ .Width }}px: too small, must be {{ $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, must be {{ $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, must be {{ $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, must be {{ $good_h -}}px in height<br>
{{ end }}
{{ end }}
{{ if eq hugo.Environment "development" }}
{{ if eq $b false }}
{{ printf "Please correct content/news/%s/%s" $slug .Name }}
{{ end }}
{{ end }}
</div>
{{ end }}
{{ if eq $b true }}
{{ $tiny := ($banner.Resize "640x q90") }}
{{ $small := ($banner.Resize "768x q90") }}
{{ $medium := ($banner.Resize "1024x q90") }}
{{ $large := ($banner.Resize "1366x q90") }}
<img loading="lazy" srcset="{{- with $tiny.RelPermalink -}}{{.}} 640w{{- end -}}
{{- with $small.RelPermalink -}}, {{.}} 768w{{- end -}}
{{- with $medium.RelPermalink -}}, {{.}} 1024w{{- end -}}
{{- with $large.RelPermalink -}}, {{.}} 1366w{{- end -}}"
src="{{ $banner.RelPermalink }}" alt="Banner Image." />
{{ end }}
{{ else }}
{{ if eq hugo.Environment "development" }}
<div class="dev left">
{{ printf "content/%sbanner* missing.." $dir }}
</div>
{{ end }}
{{ end }}
{{ partial "snippets/article_metadata" $metas }}
<div class="text">
{{ if .Description }}
<p>{{ .Description }}</p>
{{ else if .Content }}
{{ $summary := "" }}
{{ if in .RawContent "<!--more-->" }}
{{ $tmp := split .RawContent "<!--more-->" }}
{{ index $tmp 0 | markdownify }}
{{ else }}
{{ if hasPrefix .Summary "<p>" }}
{{ .Summary }}
{{ else }}
<p>{{ .Summary }} </p>
{{ end }}
{{ end }}
{{ else if $image }}
{{ $i := (.Resources.GetMatch $image) }}
{{ $tiny := ($i.Resize "640x q90") }}
{{ $small := ($i.Resize "768x q90") }}
{{ $medium := ($i.Resize "10240x q90") }}
{{ $large := ($i.Resize "1366x q90") }}
<img loading="lazy" srcset="{{- with $tiny.RelPermalink -}}{{.}} 640w{{- end -}}
{{- with $small.RelPermalink -}}, {{.}} 768w{{- end -}}
{{- with $medium.RelPermalink -}}, {{.}} 1024w{{- end -}}
{{- with $large.RelPermalink -}}, {{.}} 1366w{{- end -}}"
src="{{ $i.RelPermalink }}" alt="Banner Image." />
{{ end }}
</div>
{{ if .Truncated }}
<div class="readmore">
{{ if i18n "readmore" }}{{ i18n "readmore" }}{{ else }}{{ "read more" }}{{ end }}..
</div>
{{ end }}
</a>
</div>
{{ end }}
{{ if .paginate }}
{{ partial "snippets/paginator" (dict "paginator" $paginator) }}
{{ end }}
</div>
{{ end }}