small fixes

This commit is contained in:
teldra 2022-06-17 10:09:16 +02:00
parent 3585ec3f72
commit 18fac67a90
3 changed files with 20 additions and 80 deletions

View File

@ -66,7 +66,7 @@
} }
.black { .black {
color: black; color: var(--text-main);
} }
.left { .left {

View File

@ -70,6 +70,7 @@
{{ .Title }} {{ .Title }}
{{ if $title }}</h3>{{ else }}</h2>{{ end }} {{ if $title }}</h3>{{ else }}</h2>{{ end }}
{{ with .Resources.GetMatch $banner }} {{ with .Resources.GetMatch $banner }}
{{ $img := . }}
{{ $good_w := "1920"}} {{ $good_w := "1920"}}
{{ $good_h := "550"}} {{ $good_h := "550"}}
{{ $b := true }} {{ $b := true }}
@ -108,7 +109,15 @@
<!--<div class="img" style="background-image: url({{ .Permalink }})"> <!--<div class="img" style="background-image: url({{ .Permalink }})">
</div>--> </div>-->
{{ if eq $b true }} {{ if eq $b true }}
<img src="{{ .Permalink }}" alt="Banner Image." /> {{ $tiny := ($banner.Fill "768x280 q90") }}
{{ $small := ($banner.Fill "1024x280 q90") }}
{{ $medium := ($banner.Fill "1280x280 q90") }}
{{ $large := ($banner.Fill "1366x280 q90") }}
<img srcset="{{- with $tiny.RelPermalink -}}{{.}} 480w{{- end -}}
{{- with $small.RelPermalink -}}, {{.}} 768w{{- end -}}
{{- with $medium.RelPermalink -}}, {{.}} 1024w{{- end -}}
{{- with $large.RelPermalink -}}, {{.}} 1366w{{- end -}}"
src="{{ $banner.RelPermalink }}" alt="Banner Image." />
{{ end }} {{ end }}
{{ else }} {{ else }}
{{ if eq hugo.Environment "development" }} {{ if eq hugo.Environment "development" }}

View File

@ -7,7 +7,7 @@
{{ $good_w := "1920"}} {{ $good_w := "1920"}}
{{ $good_h := "850"}} {{ $good_h := "850"}}
{{ $what := "none" }} {{ $what := "none" }}
{{ $img := "none" }} {{ $img := "" }}
{{ if eq .Kind "home" }} {{ if eq .Kind "home" }}
{{ $what = "home" }} {{ $what = "home" }}
{{ else if eq .Kind "term" }} {{ else if eq .Kind "term" }}
@ -38,7 +38,13 @@
{{ with .File }} {{ with .File }}
{{ $slug = anchorize .ContentBaseName }} {{ $slug = anchorize .ContentBaseName }}
{{ end }} {{ end }}
{{ if and (ne $img "none") (ne .Params.banner false) }} {{ if and ($img) (ne .Params.banner false) }}
{{ if .Resources.Match "banner*" }}
{{ $img = .Resources.GetMatch "banner*" }}
{{ end }}
{{ if .Resources.ByType "image" }}
{{ $img = index (.Resources.ByType "image") 0 }}
{{ end }}
<div style="background-image: url({{- $img.Permalink -}})" class="banner {{ $css }}"> <div style="background-image: url({{- $img.Permalink -}})" class="banner {{ $css }}">
{{ if eq hugo.Environment "development" }} {{ if eq hugo.Environment "development" }}
<div class="dev right"> <div class="dev right">
@ -75,82 +81,6 @@
{{ end }} {{ end }}
{{ if not .IsHome }}<h1 class="{{ $title_class }}">{{ $title }}</h1> {{ end }} {{ if not .IsHome }}<h1 class="{{ $title_class }}">{{ $title }}</h1> {{ end }}
</div> </div>
{{ else if and (.Resources.Match "banner*") (ne .Params.banner false) }}
{{ $img = .Resources.GetMatch "banner*" }}
<div style="background-image:url({{- $img.Permalink -}})" class="banner {{ $css }}">
{{ if eq hugo.Environment "development" }}
<div class="dev right">
{{ $w := (index (.Resources.Match "banner*") 0).Width }}
{{ $h := (index (.Resources.Match "banner*") 0).Height }}
{{ if lt (int $w) $good_w }}
{{ $b = false }}
{{ 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 }}
{{ $b = false }}
{{ 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 }}
{{ $b = false }}
{{ 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 }}
{{ $b = false }}
{{ if eq hugo.Environment "development" }}
Height: {{ $h }}px: too big, better {{ $good_h -}}px in height<br>
{{ end }}
{{ end }}
{{ if eq hugo.Environment "development" }}
{{ if eq $b false }}
{{ printf "Please correct content/news/%s/%s" $slug $img.Name }}
{{ end }}
{{ end }}
</div>
{{ end }}
{{ if not .IsHome }}<h1 class="{{ $title_class }}">{{ $title }}</h1> {{ end }}
</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" }}
<div class="dev right">
{{ $w := (index (.Resources.ByType "image") 0).Width }}
{{ $h := (index (.Resources.ByType "image") 0).Height }}
{{ if lt (int $w) $good_w }}
{{ $b = false }}
{{ 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 }}
{{ $b = false }}
{{ 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 }}
{{ $b = false }}
{{ 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 }}
{{ $b = false }}
{{ if eq hugo.Environment "development" }}
Height: {{ $h }}px: too big, better {{ $good_h -}}px in height<br>
{{ end }}
{{ end }}
{{ if eq hugo.Environment "development" }}
{{ if eq $b false }}
{{ printf "Please correct content/news/%s/%s" $slug $img.Name }}
{{ end }}
{{ end }}
</div>
{{ end }}
{{ if not .IsHome }}<h1 class="{{ $title_class }}">{{ $title }}</h1> {{ end }}
</div>
{{ else }} {{ else }}
<div class="banner b altbg"> <div class="banner b altbg">
{{ if eq hugo.Environment "development" }} {{ if eq hugo.Environment "development" }}
@ -172,3 +102,4 @@
{{ if not .IsHome }}<h1 class="{{ $title_class }}">{{ $title }}</h1> {{ end }} {{ if not .IsHome }}<h1 class="{{ $title_class }}">{{ $title }}</h1> {{ end }}
</div> </div>
{{ end }} {{ end }}