{{/* 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 }}"

{{/* Resolve avatar from page bundle, site assets, remote, or static URLs */}} {{ $image_name := index $item "image" }} {{/* Initialise as boolean to avoid nil command errors in pipeline */}} {{ $image_resource := false }} {{ $image_url := "" }} {{ if $image_name }} {{ $image_path := strings.TrimSpace (printf "%v" $image_name) }} {{ $is_remote := or (strings.HasPrefix $image_path "http://") (strings.HasPrefix $image_path "https://") }} {{ if $is_remote }} {{ $remote := try (resources.GetRemote $image_path) }} {{ if and $remote (not $remote.Err) }} {{ $image_resource = $remote.Value }} {{ else }} {{/* If remote fetch fails, fall back to the original URL */}} {{ $image_url = $image_path }} {{ end }} {{ else }} {{/* Normalize common prefixes and dot paths */}} {{ $image_path = strings.TrimPrefix "/" $image_path }} {{ $image_path = strings.TrimPrefix "./" $image_path }} {{ $image_path = strings.TrimPrefix "assets/" $image_path }} {{ $image_path = strings.TrimPrefix "media/" $image_path }} {{ $normalized := path.Clean $image_path }} {{ if and $normalized (ne $normalized ".") }} {{/* Prefer page bundle image resources */}} {{ with $page }} {{ $image_resource = (.Resources.ByType "image").GetMatch $normalized }} {{ end }} {{ if not $image_resource }} {{/* Look in global assets/media - use resources.Get for exact path matching */}} {{ $image_resource = resources.Get (path.Join "media" $normalized) }} {{ end }} {{ if not $image_resource }} {{/* Static fallback (serves original size) */}} {{ $image_url = printf "/media/%s" $normalized }} {{ end }} {{ end }} {{ end }} {{ end }} {{ if $image_resource }} {{ $avatar_96 := $image_resource.Process "Fill 96x96 Center webp" }} {{ (index $item {{ else if $image_url }} {{ $is_external := or (strings.HasPrefix $image_url "http://") (strings.HasPrefix $image_url "https://") }} {{ (index $item {{ else }}
{{ end }}
{{ index $item "name" }}
{{ index $item "role" }}
{{ end }}