122 lines
5.2 KiB
HTML
122 lines
5.2 KiB
HTML
{{ $title := .Title }}
|
|
{{ $title = singularize $title }}
|
|
{{ $title = i18n $title }}
|
|
{{ if not $title }}
|
|
{{ $title = .Title }}
|
|
{{ end }}
|
|
{{ $good_w := "1920"}}
|
|
{{ $good_h := "550"}}
|
|
{{ $px := string "400" }}
|
|
{{ $fill := string (printf "1280x%s smart" $px) }}
|
|
{{ $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 $fill }}
|
|
{{ end }}
|
|
{{ if and (resources.GetMatch $banner) (ne .Params.banner false) }}
|
|
<div style="background-image: url({{- $img.Permalink -}})" class="banner">
|
|
<h1>{{ $title }}</h1>
|
|
{{ if eq hugo.Environment "development" }}
|
|
<div>
|
|
{{ $w := (resources.GetMatch $banner).Width }}
|
|
{{ $h := (resources.GetMatch $banner).Height }}
|
|
{{ if lt (int $w) $good_w }}
|
|
{{ 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 }}
|
|
{{ 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 }}
|
|
{{ 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 }}
|
|
{{ if eq hugo.Environment "development" }}
|
|
Height: {{ $h }}px: too big, better {{ $good_h -}}px in height<br>
|
|
{{ end }}
|
|
{{ end }}
|
|
</div>
|
|
{{ end }}
|
|
</div>
|
|
{{ else if and (.Resources.Match "banner*") (ne .Params.banner false) }}
|
|
{{ $img = (.Resources.GetMatch "banner*").Fill $fill }}
|
|
<div style="background-image:url({{- $img.Permalink -}})" class="banner">
|
|
<h1>{{ $title }}</h1>
|
|
{{ if eq hugo.Environment "development" }}
|
|
<div>
|
|
{{ $w := (index (.Resources.Match "banner*") 0).Width }}
|
|
{{ $h := (index (.Resources.Match "banner*") 0).Height }}
|
|
{{ if lt (int $w) $good_w }}
|
|
{{ 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 }}
|
|
{{ 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 }}
|
|
{{ 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 }}
|
|
{{ if eq hugo.Environment "development" }}
|
|
Height: {{ $h }}px: too big, better {{ $good_h -}}px in height<br>
|
|
{{ end }}
|
|
{{ end }}
|
|
</div>
|
|
{{ end }}
|
|
</div>
|
|
{{ else if and (.Resources.ByType "image") (ne .Params.banner false) }}
|
|
{{ $img = (index (.Resources.ByType "image") 0).Fill $fill }}
|
|
<div style="background-image: url({{- $img.Permalink -}})" class="banner">
|
|
<h1>{{ $title }}</h1>
|
|
{{ if eq hugo.Environment "development" }}
|
|
<div>
|
|
{{ $w := (index (.Resources.ByType "image") 0).Width }}
|
|
{{ $h := (index (.Resources.ByType "image") 0).Height }}
|
|
{{ if lt (int $w) $good_w }}
|
|
{{ 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 }}
|
|
{{ 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 }}
|
|
{{ 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 }}
|
|
{{ if eq hugo.Environment "development" }}
|
|
Height: {{ $h }}px: too big, better {{ $good_h -}}px in height<br>
|
|
{{ end }}
|
|
{{ end }}
|
|
</div>
|
|
{{ end }}
|
|
</div>
|
|
{{ else }}
|
|
<div class="banner">
|
|
<h1>{{ $title }}</h1>
|
|
{{ if eq hugo.Environment "development" }}
|
|
<p>
|
|
assets/images/banner/{{ $what -}}.* missing..<br>
|
|
or<br>
|
|
{{ with .File }}content/{{ .Dir }}/banner* missing..{{ end }}
|
|
</p>
|
|
{{ end }}
|
|
</div>
|
|
{{ end }}
|