didascalie immagini (con supporto markdown)

This commit is contained in:
Paolo Asperti 2024-07-27 18:02:17 +02:00
parent 4cdb560503
commit 793b0ff7dd
Signed by: paspo
GPG Key ID: 06D46905D19D5182
4 changed files with 32 additions and 6 deletions

View File

@ -47,3 +47,14 @@
max-width: 100%
}
}
figure {
display: inline-block;
}
figcaption {
width: 100%;
text-align: center;
font-size: smaller;
font-style: italic;
}

View File

@ -5,6 +5,8 @@ type: post
date: 2023-10-24T16:37:38+00:00
slug: linux-day-2023-agenda
image: LDbergamo-2023-banner.png
image_alt: Linuxday il 28 ottobre 2023 presso Bergamo Science Center
image_caption: "Image credits: [BgLUG](https://bglug.it 'Bergamo Linux Users Group website')"
categories:
- News
---
@ -13,10 +15,10 @@ Ecco l'agenda del LinuxDay '23.
[Iscriviti su EVENTBRITE](https://www.eventbrite.it/e/biglietti-bglug-linuxday-23-744247924577?aff=oddtdtcreator).
![Locandina Linux Day Bergamo 2023](LDbergamo-2023-3.png)
![Locandina Linux Day Bergamo 2023](LDbergamo-2023-3.png "Image credits: [BgLUG](https://bglug.it 'Bergamo Linux Users Group website')")
La lettura di **Ada&Zangemann** si svolgerà al [FabLab Bergamo APS in via M.Gavazzeni 3](https://www.openstreetmap.org/node/4712453185), poco lontano dall'evento principale.
![2Ada & Zangemann](ADA-E-ZAG-3.gif)
![2Ada & Zangemann](ADA-E-ZAG-3.gif "Image credits: [BgLUG](https://bglug.it 'Bergamo Linux Users Group website')")
[Link canva](https://tiny.cc/ada-zangemann).

View File

@ -1,5 +1,8 @@
<figure>
{{- $u := urls.Parse .Destination -}}
{{- $src := $u.String -}}
{{- $figcaption := .Title | markdownify -}}
{{- $captionWidth := 0 -}}
{{- if not $u.IsAbs -}}
{{- $path := strings.TrimPrefix "./" $u.Path }}
{{- with or (.PageInner.Resources.Get $path) (resources.Get $path) -}}
@ -14,13 +17,20 @@
{{- with $u.Fragment -}}
{{- $src = printf "%s#%s" $src . -}}
{{- end -}}
{{- $captionWidth = .Width -}}
{{- end -}}
{{- end -}}
{{- $attributes := merge .Attributes (dict "alt" .Text "src" $src "title" (.Title | transform.HTMLEscape)) -}}
<img
<img
{{- range $k, $v := $attributes -}}
{{- if $v -}}
{{- printf " %s=%q" $k $v | safeHTMLAttr -}}
{{- end -}}
{{- end -}}>
{{- with $figcaption -}}
<figcaption
{{ with $captionWidth }} style="width: {{- . -}}px;"
{{- end -}}>{{- . -}}</figcaption>
{{- end -}}
</figure>
{{- /**/ -}}

View File

@ -25,7 +25,7 @@
{{- $img = .Page.Resources.GetMatch .Params.featured -}}
{{- end -}}
<span class="image featured">
<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) -}}
@ -33,8 +33,11 @@
<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 }}
</span>
{{- end -}}
{{- with .Params.image_caption -}}
<figcaption style="width: {{- $img.Width -}}px;">{{- . | markdownify -}}</figcaption>
{{- end -}}
</figure></span>
{{ end }}
{{- .Content }}