{{ $baseURL := .Site.BaseURL }}
{{- with (.Get "dir") -}} {{- $files := readDir (print "/static/" .) }} {{- range $files -}} {{- $thumbext := $.Get "thumb" | default "-thumb" }} {{- $isthumb := .Name | findRE ($thumbext | printf "%s\\.") }} {{- $isimg := lower .Name | findRE "\\.(gif|jpg|jpeg|tiff|png|bmp|webp|avif|jxl)" }} {{- if and $isimg (not $isthumb) }} {{- $caption := .Name | replaceRE "\\..*" "" | humanize }} {{- $linkURL := print $baseURL ($.Get "dir") "/" .Name | absURL }} {{- $thumb := .Name | replaceRE "(\\.)" ($thumbext | printf "%s.") }} {{- $thumbexists := where $files "Name" $thumb }} {{- $thumbURL := print $baseURL ($.Get "dir") "/" $thumb | absURL }}
{{ $caption }}
{{- end }} {{- end }} {{- else -}} {{ .Inner }} {{- end }}