{{ $id := delimit (slice "carousel" (partial "functions/uid.html" .) (now.UnixNano)) "-" }} {{ $aspect := (split (.Get "aspectRatio") "-") }} {{ $aspectx := default "16" (index $aspect 0) }} {{ $aspecty := default "9" (index $aspect 1) }} {{ $interval := default "2000" (.Get "interval") }} {{ $page := .Page.Resources }} {{ $imagesTemp := .Get "images" }} {{ $imagesTemp = strings.TrimPrefix "{" $imagesTemp }} {{ $imagesTemp = strings.TrimSuffix "}" $imagesTemp }} {{ $imagesTemp := strings.Split $imagesTemp "," }} {{ $images := slice }} {{ range $imagesTemp }} {{ if or (strings.HasPrefix . "http:") (strings.HasPrefix . "https:") }} {{ $images = $images | append (dict "resource" (resources.GetRemote .) "key" .) }} {{ else }} {{ range ($page.Match .) }} {{ $images = $images | append (dict "resource" . "key" .Name) }} {{ end }} {{ end }} {{ end }} {{ $captionsParam := .Get "captions" }} {{ $captions := dict }} {{ if $captionsParam }} {{ $captionsTemp := strings.TrimPrefix "{" $captionsParam }} {{ $captionsTemp = strings.TrimSuffix "}" $captionsTemp }} {{ range (strings.Split $captionsTemp ",") }} {{ $pair := strings.Split . ":" }} {{ if ge (len $pair) 2 }} {{ $key := strings.TrimSpace (index $pair 0) }} {{ $value := strings.TrimSpace (delimit (after 1 $pair) ":") }} {{ $captions = merge $captions (dict $key $value) }} {{ end }} {{ end }} {{ end }} {{ if not .Parent }}
{{ end }}
{{ $num := 0 }} {{ range $images }} {{ $num = add $num 1 }} {{ end }}
{{ range $index, $image := $images }} {{ $hiddenClass := cond (eq $index 0) "" "hidden" }} {{ $resource := index $image "resource" }} {{ $key := index $image "key" }} {{ $caption := "" }} {{ $candidates := slice }} {{ if $resource }} {{ $candidates = $candidates | append $resource.Name (path.Base $resource.Name) $resource.RelPermalink (path.Base $resource.RelPermalink) }} {{ end }} {{ if $key }} {{ $candidates = $candidates | append $key (path.Base $key) }} {{ end }} {{ range $candidates }} {{ if and (not $caption) . }} {{ with (index $captions .) }}{{ $caption = . }}{{ end }} {{ end }} {{ end }}
carousel image {{ add $index 1 }}
{{ if $caption }}
{{ $caption | markdownify }}
{{ end }}
{{ end }}