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

144 lines
4.9 KiB
HTML
Raw Normal View History

2022-06-17 17:45:53 +02:00
{{ define "debug" }}
{{ .Section }}<br>
{{ end }}
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" }}
2022-06-17 10:09:16 +02:00
{{ $img := "" }}
2022-05-06 13:29:00 +02:00
{{ 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-17 17:45:53 +02:00
{{ if and $img (ne .Params.banner false) }}
2022-06-17 10:09:16 +02:00
{{ if .Resources.Match "banner*" }}
2022-06-12 23:48:26 +02:00
{{ $img = .Resources.GetMatch "banner*" }}
2022-06-17 10:09:16 +02:00
{{ end }}
{{ if .Resources.ByType "image" }}
2022-06-15 14:18:00 +02:00
{{ $img = index (.Resources.ByType "image") 0 }}
2022-06-17 10:09:16 +02:00
{{ end }}
2022-06-17 10:20:00 +02:00
{{ if $img }}
2022-06-17 17:45:53 +02:00
{{ $tiny := ($img.Resize "640x q90") }}
{{ $small := ($img.Resize "768x q90") }}
{{ $medium := ($img.Resize "10240x q90") }}
{{ $large := ($img.Resize "1366x q90") }}
<style>
@media (min-width: 40em) {
.ttestt {
background-image: url({{- $tiny.Permalink -}});
}
}
@media (min-width: 48em) {
.ttestt {
background-image: url({{- $small.Permalink -}});
}
}
@media (min-width: 64em) {
.ttestt {
background-image: url({{- $medium.Permalink -}});
}
}
@media (min-width: 85.375em) {
.ttestt {
background-image: url({{- $large.Permalink -}});
}
}
@media (min-width: 120em) {
.ttestt {
background-image: url({{- $img.Permalink -}});
}
}
</style>
<div class="ttestt banner {{ $css }}">
2022-06-15 14:18:00 +02:00
{{ if eq hugo.Environment "development" }}
2022-06-15 17:10:36 +02:00
<div class="dev right">
2022-06-17 10:20:00 +02:00
{{ $w := $img.Width }}
{{ $h := $img.Height }}
2022-06-15 14:18:00 +02:00
{{ 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-06-17 10:20:00 +02:00
{{ end }}
2022-06-17 10:27:07 +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 }}
2022-06-17 10:09:16 +02:00