update theme

This commit is contained in:
Christoph Cullmann 2025-07-18 21:45:32 +02:00
parent fc43dba964
commit 93fea0ed81
No known key found for this signature in database
183 changed files with 6015 additions and 6241 deletions

View file

@ -1,31 +1,31 @@
{{ $id := delimit (slice "gallery" (partial "functions/uid.html" .)) "-" }}
{{ $id := delimit (slice "gallery" (partial "functions/uid.html" .)) "-" -}}
{{ $content := .Inner -}}
<div id="{{ $id }}" class="gallery">
{{ $page := .Page }}
{{/* find all img tags */}}
{{ $imgTagRegex := `<img\s+[^>]*>` }}
{{ $imgTags := findRE $imgTagRegex .Inner }}
{{ $newContent := .Inner }}
{{ range $imgTags }}
{{ $imgTag := . }}
{{/* extract src attribute */}}
{{ $srcRegex := `src=['"]([^'"]+)['"]` }}
{{ $srcMatches := findRESubmatch $srcRegex $imgTag }}
{{ if $srcMatches }}
{{ $srcFull := index (index $srcMatches 0) 0 }}
{{ $src := index (index $srcMatches 0) 1 }}
{{ $resource := $page.Resources.GetMatch $src }}
{{ if $resource }}
{{ $newSrc := printf `src="%s"` $resource.RelPermalink }}
{{ $newImg := replace $imgTag $srcFull $newSrc }}
{{ $newContent = replace $newContent $imgTag $newImg }}
{{ end }}
{{ end }}
{{ end }}
{{ $newContent | safeHTML }}
{{/* find all img tags */}}
{{ range findRE `<img\s+[^>]*>` $content -}}
{{ $imgTag := . -}}
{{/* extract src attribute */}}
{{ with findRESubmatch `src=['"]([^'"]+)['"]` $imgTag -}}
{{ $srcAttr := index (index . 0) 0 -}}
{{ $srcValue := index (index . 0) 1 -}}
{{ $srcValueFinal := $srcValue -}}
{{ if or (hasPrefix $srcValue "http://") (hasPrefix $srcValue "https://") -}}
{{ with resources.GetRemote $srcValue -}}{{ $srcValueFinal = .RelPermalink -}}{{ end -}}
{{ else -}}
{{ with $.Page.Resources.GetMatch $srcValue -}}
{{ $srcValueFinal = .RelPermalink -}}
{{ else -}}
{{ with resources.GetMatch $srcValue -}}{{ $srcValueFinal = .RelPermalink -}}{{ end -}}
{{ end -}}
{{ end -}}
{{ $newTag := replace $imgTag $srcAttr (printf `src="%s"` $srcValueFinal) -}}
{{ $content = replace $content $imgTag $newTag -}}
{{ end -}}
{{ end -}}
<div id="{{- $id -}}" class="gallery">
{{ $content | safeHTML -}}
</div>