{{/* Hugo Blox: Testimonials */}} {{/* Documentation: https://hugoblox.com/blocks/ */}} {{/* License: https://github.com/HugoBlox/kit/blob/main/LICENSE.md */}} {{/* Initialise */}} {{ $page := .wcPage }} {{ $block := .wcBlock }} {{ $content := $block.content }} {{ if not (reflect.IsMap $content) }}{{ $content = dict }}{{ end }} {{ $title := "" }} {{ $title_raw := index $content "title" }} {{ if $title_raw }} {{ $title = strings.TrimSpace (printf "%v" $title_raw) }} {{ end }} {{ if $title }}{{ $title = $title | emojify | $page.RenderString }}{{ end }} {{ $text := "" }} {{ $text_raw := index $content "text" }} {{ if $text_raw }} {{ $text = strings.TrimSpace (printf "%v" $text_raw) }} {{ end }} {{ if $text }}{{ $text = $text | emojify | $page.RenderString }}{{ end }} {{ $items_raw := index $content "items" }} {{ $items_iter := slice }} {{ if reflect.IsSlice $items_raw }} {{ $items_iter = $items_raw }} {{ else if and $items_raw (reflect.IsMap $items_raw) }} {{ $items_iter = slice $items_raw }} {{ end }} {{ $items := slice }} {{ if gt (len $items_iter) 0 }} {{ range $items_iter }} {{ if reflect.IsMap . }} {{ $item_text := "" }} {{ $item_name := "" }} {{ $item_role := "" }} {{ $item_image := "" }} {{ with index . "text" }}{{ $item_text = strings.TrimSpace (printf "%v" .) }}{{ end }} {{ with index . "name" }}{{ $item_name = strings.TrimSpace (printf "%v" .) }}{{ end }} {{ with index . "role" }}{{ $item_role = strings.TrimSpace (printf "%v" .) }}{{ end }} {{ with index . "image" }}{{ $item_image = strings.TrimSpace (printf "%v" .) }}{{ end }} {{ if or $item_text $item_name $item_role $item_image }} {{ $items = $items | append (dict "text" $item_text "name" $item_name "role" $item_role "image" $item_image) }} {{ end }} {{ end }} {{ end }} {{ end }}
{{ with $title }}

{{.}}

{{ with $text }}

{{.}}

{{ end }}
{{ end }} {{ range $idx, $item := $items }}

"{{ (index $item "text") | $page.RenderString }}"

{{ $image_name := index $item "image" }} {{ $image_path := "" }} {{ if $image_name }}{{ $image_path = path.Join "media" (strings.TrimPrefix $image_name "/") }}{{ end }} {{ $image := "" }} {{ if $image_path }}{{ $image = resources.GetMatch $image_path }}{{ end }} {{ with $image }} {{/* Serve a single 2x retina source for a 48px display */}} {{ $avatar_96 := $image.Process "Fill 96x96 Center webp" }} {{ (index $item {{ end }}
{{ index $item "name" }}
{{ index $item "role" }}
{{ end }}