bunteshaus.de/themes/buha/layouts/partials/snippets/banner_new.html

73 lines
2.2 KiB
HTML
Raw Normal View History

2022-06-22 18:15:37 +02:00
{{ $img := .image }}
{{ if .Resources.GetMatch .image }}
{{ $img = .Resources.GetMatch .image }}
{{ else if resources.GetMatch .image }}
{{ $img = resources.GetMatch .image }}
{{ end }}
{{ $title := .title }}
{{ $good_w := "1920"}}
{{ $good_h := "850"}}
{{ $banner := .context.Params.banner }}
{{ $test := true }}
{{ if and $img (ne $banner false) }}
{{ $tiny := ($img.Resize "640x q90") }}
{{ $small := ($img.Resize "768x q90") }}
{{ $medium := ($img.Resize "10240x q90") }}
{{ $large := ($img.Resize "1366x q90") }}
<div class="ttestt banner b" style="background-image: url({{- $img.Permalink -}});">
{{ if eq hugo.Environment "development" }}
<div class="dev right">
{{ $w := $img.Width }}
{{ $h := $img.Height }}
{{ if lt (int $w) $good_w }}
{{ $test = false }}
{{ if eq hugo.Environment "development" }}
Width: {{ $w }}px: too small, better {{ $good_w -}}px in width<br>
{{ end }}
{{ else if gt (int $w) $good_w }}
{{ $test = false }}
{{ if eq hugo.Environment "development" }}
Width: {{ $w }}px: too big, better {{ $good_w -}}px in width<br>
{{ end }}
{{ end }}
{{ if lt (int $h) $good_h }}
{{ $test = false }}
{{ if eq hugo.Environment "development" }}
Height: {{ $h }}px: too small, better {{ $good_h -}}px in height<br>
{{ end }}
{{ else if gt (int $h) $good_h }}
{{ $test = false }}
{{ if eq hugo.Environment "development" }}
Height: {{ $h }}px: too big, better {{ $good_h -}}px in height<br>
{{ end }}
{{ end }}
{{ if eq hugo.Environment "development" }}
{{ if eq $test false }}
{{ printf "Please correct %s" $img }}
{{ end }}
{{ end }}
</div>
{{ end }}
{{ if $title }}<h1 class="title">{{ $title }}</h1> {{ end }}
</div>
{{ else }}
<div class="banner b altbg">
{{ if eq hugo.Environment "development" }}
{{ $c := "" }}
{{ $str := "" }}
{{ if eq $banner false }}
{{ $c = "black" }}
{{ $str = "Info: Banner is turned off for this." }}
{{ else }}
{{ $str = printf "content/%s/banner* missing.." .section }}
{{ end }}
<div class="dev right {{ $c }}">
{{ $str }}
</div>
{{ end }}
{{ if $title }}<h1 class="title">{{ $title }}</h1> {{ end }}
</div>
{{ end }}