feat: Automatisation

This commit is contained in:
2022-02-02 17:38:21 +01:00
parent 7b91c01605
commit e1a552c526
24 changed files with 427 additions and 58 deletions

View File

@ -2,17 +2,18 @@
{{ $resources := .Page.Resources }}
</div>
</div>
<div class="masonry" itemscope itemtype="http://schema.org/ImageGallery">
{{ range .Params }}
<figure itemscope class="brick" itemtype="http://schema.org/ImageObject">
{{ $path := . }}
{{ $text := "" }}
{{ if in . ":" }}
{{ $arg := split . ":" }}
{{ $path = index $arg 0 }}
{{ $text = index $arg 1 }}
{{ end }}
{{ $images := split (trim .Inner "\n") "!" }}
{{ $patternTitle := "\\[([^]]*)\\]\\(.*\\)" }}
{{ $patternPath := "\\[.*\\]\\(([^)]*)\\)" }}
<div class="masonry" itemscope itemtype="http://schema.org/ImageGallery">
{{ range $images }}
{{ with . }}
{{ $title := replaceRE $patternTitle "$1" . }}
{{ $path := trim (replaceRE $patternPath "$1" .) " \n" }}
<figure itemscope class="brick" itemtype="http://schema.org/ImageObject">
{{ $image := $resources.GetMatch (printf "*%s*" $path) }}
{{ $orientation := 1 }}
{{ with $image }}{{ with .Exif }}{{ $orientation = .Tags.Orientation }}{{ end }}{{ end }}
@ -22,9 +23,10 @@
{{ $image = $image.Resize "300x r270" }}
{{ end }}
{{ $resized := $image.Resize "300x q100 webp" }}
<img src="{{ $resized.RelPermalink }}" alt="{{ $text }}" title="{{ $text }}" loading="lazy">
<img src="{{ $resized.RelPermalink }}" alt="{{ $title }}" title="{{ $title }}" loading="lazy">
</figure>
{{ end }}
{{ end }}
</div>
<div class="container">
<div class="container news md">