{{/* Hugo Blox: CTA Image Paragraph */}} {{/* 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 }}
{{ $items_raw := index $content "items" }} {{ $items := slice }} {{ if reflect.IsSlice $items_raw }} {{ $items = $items_raw }} {{ else if and $items_raw (reflect.IsMap $items_raw) }} {{ $items = slice $items_raw }} {{ end }} {{ range $idx, $item := $items }} {{ if reflect.IsMap $item }} {{ $title := "" }} {{ $title_raw := index $item "title" }} {{ if eq (printf "%T" $title_raw) "string" }}{{ $title = $title_raw | emojify | $page.RenderString }}{{ end }} {{ $text := "" }} {{ $text_raw := index $item "text" }} {{ if eq (printf "%T" $text_raw) "string" }}{{ $text = $text_raw | emojify | $page.RenderString }}{{ end }} {{ $image_name := "" }} {{ $image_raw := index $item "image" }} {{ if eq (printf "%T" $image_raw) "string" }}{{ $image_name = strings.TrimSpace $image_raw }}{{ end }} {{ $image_path := "" }} {{ if $image_name }}{{ $image_path = path.Join "media" $image_name }}{{ end }} {{ $image := "" }} {{ if $image_path }}{{ $image = resources.GetMatch $image_path }}{{ end }} {{ if $image }}
{{ if ne $image.MediaType.SubType "gif" }} {{ $responsive := partial "functions/process_responsive_image.html" (dict "image" $image "mode" "fit" "sizes" (slice 400 600 800 1200) ) }} {{$title | plainify}} {{ else }} {{$title | plainify}} {{ end }} {{ else }} {{ warnf "%s uses the `cta-image-paragraph` blox which specifies a non-existent `image` at `assets/%s`. Skipping this item." $page.File.Path $image_path }} {{ end }}

{{$title}}

{{$text}}

{{ $icon := "check" }} {{ $icon_raw := index $item "feature_icon" }} {{ if eq (printf "%T" $icon_raw) "string" }}{{ $icon = $icon_raw }}{{ end }} {{ $features_raw := index $item "features" }} {{ $features := slice }} {{ if reflect.IsSlice $features_raw }} {{ $features = $features_raw }} {{ else if eq (printf "%T" $features_raw) "string" }} {{ $features = slice $features_raw }} {{ end }} {{ if gt (len $features) 0 }}
    {{ range $features }}
  • {{ partial "functions/get_icon" (dict "name" $icon "attributes" `class="inline-block pr-3" style="height: 1em;"`) }} {{ printf "%v" . | markdownify }}
  • {{ end }}
{{ end }} {{ $button_raw := index $item "button" }} {{ if and $button_raw (reflect.IsMap $button_raw) }} {{ $button_text := "" }} {{ $button_url := "" }} {{ with index $button_raw "text" }}{{ $button_text = strings.TrimSpace (printf "%v" .) }}{{ end }} {{ with index $button_raw "url" }}{{ $button_url = strings.TrimSpace (printf "%v" .) }}{{ end }} {{ if and $button_text $button_url }} {{ $link := $button_url }} {{ $target := "" }} {{ $scheme := (urls.Parse $link).Scheme }} {{ if not $scheme }} {{ if not (hasPrefix $link "#") }} {{ $link = $link | relLangURL }} {{ end }} {{ if eq (path.Ext $link) ".pdf" }}{{ $target = "target=\"_blank\" rel=\"noopener\"" }}{{ end }} {{ else if in (slice "http" "https") $scheme }} {{ $target = "target=\"_blank\" rel=\"noopener\"" }} {{ end }} {{ $button_text }} {{ end }} {{ end }}
{{ end }} {{ end }}