bglug.it/layouts/_default/single.html
paspo f910647729 fix dimensione immagini didascalie su mobile (#158)
fix #157

Reviewed-on: BgLUG/bglug.it#158
Co-authored-by: paspo <paolo@asperti.com>
Co-committed-by: paspo <paolo@asperti.com>
2024-07-28 09:43:59 +00:00

45 lines
1.6 KiB
HTML

{{ define "main" }}
<header>
<h2>{{ .Title }}</h2>
<p>{{ .Description }}</p>
{{ if .Site.Params.show_post_dates | default true }}
{{- with .Date }}<time>{{ . | time.Format ":date_medium" }}</time>{{ end }}
{{ end }}
{{ partial "tags.html" . }}
</header>
{{- if or .Params.image .Params.featured }}
{{- $maxHeight := 600 -}}
{{- $ratio := 2.33 -}}
{{ $rasters := slice "jpeg" "png" }}
{{- $img := "#" -}}
{{- if .Params.image -}}
{{/* se è stata definita un'immagine featured */}}
{{- $img = .Page.Resources.GetMatch .Params.image -}}
{{- end -}}
{{- if .Params.featured -}}
{{/* se è stata definita un'immagine featured */}}
{{- $img = .Page.Resources.GetMatch .Params.featured -}}
{{- end -}}
<span class="image featured"><figure>
{{- if in $rasters $img.MediaType.SubType -}}
{{- if gt $img.Height $maxHeight -}}
{{- $img = $img.Resize (printf "x%d webp q50" $maxHeight) -}}
{{- end -}}
<img src="{{ $img.RelPermalink }}" alt="{{ .Params.image_alt }}" {{- if ge (mul $img.Height $ratio) $img.Width -}}style="width: auto;" {{- end -}}/>
{{ else }}
<img src="{{ $img.RelPermalink }}" alt="{{ .Params.image_alt }}" />
{{- end -}}
{{- with .Params.image_caption -}}
<figcaption style="max-width: {{- $img.Width -}}px;">{{- . | markdownify -}}</figcaption>
{{- end -}}
</figure></span>
{{ end }}
{{- .Content }}
{{ end }}