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

175 lines
7.5 KiB
HTML
Raw Normal View History

2022-05-06 11:49:30 +02:00
{{ $title := .Title }}
{{ $title = singularize $title }}
{{ $title = i18n $title }}
{{ if not $title }}
{{ $title = .Title }}
{{ end }}
2022-06-12 19:27:57 +02:00
{{ $good_w := "1920"}}
2022-06-15 11:48:59 +02:00
{{ $good_h := "850"}}
2022-05-06 13:29:00 +02:00
{{ $what := "none" }}
{{ $img := "none" }}
{{ if eq .Kind "home" }}
{{ $what = "home" }}
2022-06-15 14:18:00 +02:00
{{ else if eq .Kind "term" }}
{{ $what = printf "term/%s" (anchorize .Title) }}
{{ else if eq .Kind "taxonomy" }}
{{ $what = .Data.Singular }}
{{ else }}
2022-05-06 14:01:05 +02:00
{{ with .File }}
{{ $what = .File.ContentBaseName }}
{{ end }}
2022-05-06 13:29:00 +02:00
{{ end }}
2022-06-12 21:14:14 +02:00
{{ $title_class := safeCSS "title" }}
2022-06-13 04:08:02 +02:00
{{ $css := safeCSS "b" }}
2022-06-12 21:14:14 +02:00
{{ if .IsHome }}
2022-06-13 04:08:02 +02:00
{{ $css = safeCSS "b_index" }}
2022-06-12 21:14:14 +02:00
{{ $title_class = safeCSS "title_index" }}
{{ end }}
2022-06-15 14:18:00 +02:00
{{ $banner := string (printf "/images/banner/%s*" $what) }}
2022-05-06 13:29:00 +02:00
{{ if resources.GetMatch $banner }}
2022-06-12 23:48:26 +02:00
{{ $img = resources.GetMatch $banner }}
2022-05-06 13:29:00 +02:00
{{ end }}
2022-06-13 04:08:02 +02:00
{{ $single := false }}
{{ if and (in .File "news/") (not (in .File "_index"))}}
{{ $single = true }}
{{ end }}
2022-06-15 18:17:00 +02:00
{{ $b := true }}
2022-06-15 18:21:36 +02:00
{{ $slug := "" }}
{{ with .File }}
{{ $slug = anchorize .ContentBaseName }}
{{ end }}
2022-06-13 04:08:02 +02:00
{{ if and (ne $img "none") (ne .Params.banner false) }}
<div style="background-image: url({{- $img.Permalink -}})" class="banner {{ $css }}">
2022-06-12 17:24:42 +02:00
{{ if eq hugo.Environment "development" }}
2022-06-15 17:10:36 +02:00
<div class="dev right">
2022-06-12 19:27:57 +02:00
{{ $w := (resources.GetMatch $banner).Width }}
{{ $h := (resources.GetMatch $banner).Height }}
{{ if lt (int $w) $good_w }}
2022-06-15 18:17:00 +02:00
{{ $b = false }}
2022-06-12 19:27:57 +02:00
{{ if eq hugo.Environment "development" }}
2022-06-15 14:18:00 +02:00
Width: {{ $w }}px: too small, better {{ $good_w -}}px in width<br>
2022-06-12 19:27:57 +02:00
{{ end }}
{{ else if gt (int $w) $good_w }}
2022-06-15 18:17:00 +02:00
{{ $b = false }}
2022-06-12 19:27:57 +02:00
{{ if eq hugo.Environment "development" }}
2022-06-15 14:18:00 +02:00
Width: {{ $w }}px: too big, better {{ $good_w -}}px in width<br>
2022-06-12 19:27:57 +02:00
{{ end }}
{{ end }}
{{ if lt (int $h) $good_h }}
2022-06-15 18:17:00 +02:00
{{ $b = false }}
2022-06-12 19:27:57 +02:00
{{ if eq hugo.Environment "development" }}
2022-06-15 14:18:00 +02:00
Height: {{ $h }}px: too small, better {{ $good_h -}}px in height<br>
2022-06-12 19:27:57 +02:00
{{ end }}
{{ else if gt (int $h) $good_h }}
2022-06-15 18:17:00 +02:00
{{ $b = false }}
2022-06-12 19:27:57 +02:00
{{ if eq hugo.Environment "development" }}
2022-06-15 14:18:00 +02:00
Height: {{ $h }}px: too big, better {{ $good_h -}}px in height<br>
2022-06-12 19:27:57 +02:00
{{ end }}
{{ end }}
2022-06-15 18:17:00 +02:00
{{ if eq hugo.Environment "development" }}
{{ if eq $b false }}
{{ printf "Please correct content/news/%s/%s" $slug $img.Name }}
{{ end }}
{{ end }}
2022-06-07 20:15:31 +02:00
</div>
{{ end }}
2022-06-15 15:42:06 +02:00
{{ if not .IsHome }}<h1 class="{{ $title_class }}">{{ $title }}</h1> {{ end }}
2022-06-07 20:15:31 +02:00
</div>
2022-05-09 21:37:34 +02:00
{{ else if and (.Resources.Match "banner*") (ne .Params.banner false) }}
2022-06-12 23:48:26 +02:00
{{ $img = .Resources.GetMatch "banner*" }}
2022-06-13 04:08:02 +02:00
<div style="background-image:url({{- $img.Permalink -}})" class="banner {{ $css }}">
2022-06-12 17:24:42 +02:00
{{ if eq hugo.Environment "development" }}
2022-06-15 17:10:36 +02:00
<div class="dev right">
2022-06-12 19:27:57 +02:00
{{ $w := (index (.Resources.Match "banner*") 0).Width }}
{{ $h := (index (.Resources.Match "banner*") 0).Height }}
{{ if lt (int $w) $good_w }}
2022-06-15 18:17:00 +02:00
{{ $b = false }}
2022-06-12 19:27:57 +02:00
{{ if eq hugo.Environment "development" }}
2022-06-15 14:18:00 +02:00
Width: {{ $w }}px: too small, better {{ $good_w -}}px in width<br>
{{ end }}
{{ else if gt (int $w) $good_w }}
2022-06-15 18:17:00 +02:00
{{ $b = false }}
2022-06-15 14:18:00 +02:00
{{ 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 }}
2022-06-15 18:17:00 +02:00
{{ $b = false }}
2022-06-15 14:18:00 +02:00
{{ 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 }}
2022-06-15 18:17:00 +02:00
{{ $b = false }}
2022-06-15 14:18:00 +02:00
{{ if eq hugo.Environment "development" }}
Height: {{ $h }}px: too big, better {{ $good_h -}}px in height<br>
{{ end }}
{{ end }}
2022-06-15 18:17:00 +02:00
{{ if eq hugo.Environment "development" }}
{{ if eq $b false }}
{{ printf "Please correct content/news/%s/%s" $slug $img.Name }}
{{ end }}
{{ end }}
2022-06-15 14:18:00 +02:00
</div>
{{ end }}
2022-06-15 15:42:06 +02:00
{{ if not .IsHome }}<h1 class="{{ $title_class }}">{{ $title }}</h1> {{ end }}
2022-06-15 14:18:00 +02:00
</div>
{{ else if and (.Resources.ByType "image") (ne .Params.banner false) (not true) }}
{{ $img = index (.Resources.ByType "image") 0 }}
<div style="background-image: url({{- $img.Permalink -}})" class="banner {{ $css }}">
{{ if eq hugo.Environment "development" }}
2022-06-15 17:10:36 +02:00
<div class="dev right">
2022-06-15 14:18:00 +02:00
{{ $w := (index (.Resources.ByType "image") 0).Width }}
{{ $h := (index (.Resources.ByType "image") 0).Height }}
{{ if lt (int $w) $good_w }}
2022-06-15 18:17:00 +02:00
{{ $b = false }}
2022-06-15 14:18:00 +02:00
{{ if eq hugo.Environment "development" }}
Width: {{ $w }}px: too small, better {{ $good_w -}}px in width<br>
2022-06-12 19:27:57 +02:00
{{ end }}
{{ else if gt (int $w) $good_w }}
2022-06-15 18:17:00 +02:00
{{ $b = false }}
2022-06-12 19:27:57 +02:00
{{ if eq hugo.Environment "development" }}
2022-06-15 14:18:00 +02:00
Width: {{ $w }}px: too big, better {{ $good_w -}}px in width<br>
2022-06-12 19:27:57 +02:00
{{ end }}
{{ end }}
{{ if lt (int $h) $good_h }}
2022-06-15 18:17:00 +02:00
{{ $b = false }}
2022-06-12 19:27:57 +02:00
{{ if eq hugo.Environment "development" }}
2022-06-15 14:18:00 +02:00
Height: {{ $h }}px: too small, better {{ $good_h -}}px in height<br>
2022-06-12 19:27:57 +02:00
{{ end }}
{{ else if gt (int $h) $good_h }}
2022-06-15 18:17:00 +02:00
{{ $b = false }}
2022-06-12 19:27:57 +02:00
{{ if eq hugo.Environment "development" }}
2022-06-15 14:18:00 +02:00
Height: {{ $h }}px: too big, better {{ $good_h -}}px in height<br>
2022-06-12 19:27:57 +02:00
{{ end }}
2022-06-15 18:17:00 +02:00
{{ end }}
{{ if eq hugo.Environment "development" }}
{{ if eq $b false }}
{{ printf "Please correct content/news/%s/%s" $slug $img.Name }}
{{ end }}
2022-06-12 19:27:57 +02:00
{{ end }}
2022-06-12 17:24:42 +02:00
</div>
{{ end }}
2022-06-15 15:42:06 +02:00
{{ if not .IsHome }}<h1 class="{{ $title_class }}">{{ $title }}</h1> {{ end }}
2022-06-07 20:15:31 +02:00
</div>
2022-05-06 13:29:00 +02:00
{{ else }}
2022-06-15 15:37:23 +02:00
<div class="banner b altbg">
2022-06-12 17:24:42 +02:00
{{ if eq hugo.Environment "development" }}
2022-06-13 04:08:02 +02:00
{{ if eq .Params.banner false }}
2022-06-15 17:10:36 +02:00
<div class="dev right black">
2022-06-15 15:46:35 +02:00
Info: Banner is turned off for this.
2022-06-13 04:08:02 +02:00
{{ else }}
2022-06-15 17:10:36 +02:00
<div class="dev right">
2022-06-13 04:08:02 +02:00
{{ if eq $single true }}
2022-06-15 14:18:00 +02:00
{{ with .File }}
{{ printf "content/%sbanner* missing.." .Dir }}
{{ end }}
2022-06-13 04:08:02 +02:00
{{ else if eq $single false }}
2022-06-15 14:18:00 +02:00
{{ printf "assets/images/banner/%s* missing.." $what }}
2022-06-13 04:08:02 +02:00
{{ end }}
{{ end }}
2022-06-15 15:42:06 +02:00
</div>
2022-06-12 17:24:42 +02:00
{{ end }}
2022-06-15 15:42:06 +02:00
{{ if not .IsHome }}<h1 class="{{ $title_class }}">{{ $title }}</h1> {{ end }}
2022-06-12 17:24:42 +02:00
</div>
2022-05-06 11:49:30 +02:00
{{ end }}