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

39 lines
2.3 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-05-09 23:17:23 +02:00
{{ $px := string "400" }}
{{ $fill := string (printf "1280x%s smart" $px) }}
2022-05-10 04:16:08 +02:00
{{ $all := "" }}
2022-05-22 23:49:19 +02:00
{{ $style := safeCSS "text-shadow: 0px 3px 0px #b2a98f, 0px 14px 10px rgba(0,0,0,0.15), 0px 24px 2px rgba(0,0,0,0.1), 0px 34px 30px rgba(0,0,0,0.1)" }}
2022-05-06 13:29:00 +02:00
{{ $what := "none" }}
{{ $img := "none" }}
{{ if eq .Kind "home" }}
{{ $what = "home" }}
2022-05-06 14:01:05 +02:00
{{ else }}
{{ with .File }}
{{ $what = .File.ContentBaseName }}
{{ end }}
2022-05-06 13:29:00 +02:00
{{ end }}
{{ $banner := printf "/images/banner/%s*" $what }}
{{ if resources.GetMatch $banner }}
2022-05-09 23:17:23 +02:00
{{ $img = (resources.GetMatch $banner).Fill $fill }}
2022-05-06 13:29:00 +02:00
{{ end }}
2022-05-09 23:17:23 +02:00
{{ $height := safeCSS (printf "min-height: calc(%spx - 5rem); max-height: calc(%spx - 5rem);" $px $px) }}
2022-05-09 21:37:34 +02:00
{{ if and (resources.GetMatch $banner) (ne .Params.banner false) }}
2022-05-09 23:01:43 +02:00
{{ $height = safeCSS (printf "height: calc(%spx - 5rem);" (string $img.Height)) }}
2022-05-22 23:49:19 +02:00
<div style="background-image: linear-gradient(rgba(0, 0, 0, 0.3), rgba(0, 0, 0, 0.1)), url({{- $img.Permalink -}}); {{ $height }}" class="banner banner-shadow"><h1 class="funny-text-shadow">{{ $title }}</h1></div>
2022-05-09 21:37:34 +02:00
{{ else if and (.Resources.Match "banner*") (ne .Params.banner false) }}
2022-05-09 23:17:23 +02:00
{{ $img = (.Resources.GetMatch "banner*").Fill $fill }}
2022-05-09 23:01:43 +02:00
{{ $height = safeCSS (printf "height: calc(%spx - 5rem);" (string $img.Height)) }}
2022-05-22 23:49:19 +02:00
<div style="background-image: linear-gradient(rgba(0, 0, 0, 0.3), rgba(0, 0, 0, 0.1)), url({{- $img.Permalink -}}); {{ $height }}" class="banner banner-shadow"><h1 class="funny-text-shadow">{{ $title }}</h1></div>
2022-05-10 04:16:08 +02:00
{{ else if and (.Resources.ByType "image") (ne .Params.banner false) $all }}
2022-05-09 23:17:23 +02:00
{{ $img = (index (.Resources.ByType "image") 0).Fill $fill }}
2022-05-09 23:01:43 +02:00
{{ $height = safeCSS (printf "height: calc(%spx - 5rem);" (string $img.Height)) }}
2022-05-22 23:49:19 +02:00
<div style="background-image: linear-gradient(rgba(0, 0, 0, 0.3), rgba(0, 0, 0, 0.1)), url({{- $img.Permalink -}}); {{ $height }}" class="banner banner-shadow"><h1 class="funny-text-shadow">{{ $title }}</h1></div>
2022-05-06 13:29:00 +02:00
{{ else }}
2022-05-22 23:49:19 +02:00
<div style="background-image: linear-gradient(rgba(0, 0, 0, 0.3), rgba(0, 0, 0, 0.1)); {{ $height }}" class="banner"><h1 class="funny-text-shadow">{{ $title }}</h1></div>
2022-05-06 11:49:30 +02:00
{{ end }}