diff --git a/layouts/shortcodes/carousel.html b/layouts/shortcodes/carousel.html index 64f6d728..9f3cd004 100644 --- a/layouts/shortcodes/carousel.html +++ b/layouts/shortcodes/carousel.html @@ -1,93 +1,75 @@ {{ $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) }} +{{ $aspectx := default "16" (index $aspect 0) }} +{{ $aspecty := default "9" (index $aspect 1) }} {{ $interval := default "2000" (.Get "interval") }} +{{ $imagesParam := .Get "images" }} +{{ $items := slice }} {{ $page := .Page.Resources }} -{{ $imagesTemp := .Get "images" }} +{{ $imagesTemp := $imagesParam }} {{ $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 }} + {{ if or (strings.HasPrefix . "http:") (strings.HasPrefix . "https:") }} + {{ $items = $items | append (dict "resource" (resources.GetRemote .) "key" .) }} + {{ else }} + {{ range ($page.Match .) }} + {{ $items = $items | 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 }} + {{ $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 }}