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

33 lines
1.6 KiB
HTML

{{ $title := .Title }}
{{ $title = singularize $title }}
{{ $title = i18n $title }}
{{ if not $title }}
{{ $title = .Title }}
{{ end }}
{{ $what := "none" }}
{{ $img := "none" }}
{{ if eq .Kind "home" }}
{{ $what = "home" }}
{{ else }}
{{ with .File }}
{{ $what = .File.ContentBaseName }}
{{ end }}
{{ end }}
{{ $banner := printf "/images/banner/%s*" $what }}
{{ if resources.GetMatch $banner }}
{{ $img = (resources.GetMatch $banner).Fill "1280x480 smart" }}
{{ end }}
{{ if and (resources.GetMatch $banner) (ne .Params.banner false) }}
<div style="background-image: linear-gradient(rgba(0, 0, 0, 0.3), rgba(0, 0, 0, 0.1)), url({{- $img.Permalink -}});" class="banner banner-shadow"><h1 class="dark-shadow">{{ $title }}</h1></div>
{{ else if and (.Resources.Match "banner*") (ne .Params.banner false) }}
{{ $img = (.Resources.GetMatch "banner*").Fill "1280x480 smart" }}
<div style="background-image: linear-gradient(rgba(0, 0, 0, 0.3), rgba(0, 0, 0, 0.1)), url({{- $img.Permalink -}});" class="banner banner-shadow"><h1 class="dark-shadow">{{ $title }}</h1></div>
{{ else if and (.Resources.ByType "image") (ne .Params.banner false) }}
{{ $img = (index (.Resources.ByType "image") 0).Fill "1280x480 smart" }}
<div style="background-image: linear-gradient(rgba(0, 0, 0, 0.3), rgba(0, 0, 0, 0.1)), url({{- $img.Permalink -}});" class="banner banner-shadow"><h1 class="dark-shadow">{{ $title }}</h1></div>
{{ else }}
<div style="background-image: linear-gradient(rgba(0, 0, 0, 0.3), rgba(0, 0, 0, 0.1))" class="banner"><h1>{{ $title }}</h1></div>
{{ end }}