{{/* Hugo Blox: Hero */}} {{/* 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 }} {{ $design := $block.design }} {{ if not (reflect.IsMap $design) }}{{ $design = dict }}{{ end }} {{ $no_padding := partial "functions/coerce_bool" (dict "value" (index $design "no_padding") "default" false) }} {{ $announcement := index $content "announcement" }} {{ if not (reflect.IsMap $announcement) }}{{ $announcement = dict }}{{ end }} {{ $announcement_text := "" }} {{ with index $announcement "text" }}{{ $announcement_text = strings.TrimSpace (printf "%v" .) }}{{ end }} {{ $announcement_link := index $announcement "link" }} {{ if not (reflect.IsMap $announcement_link) }}{{ $announcement_link = dict }}{{ end }} {{ $announcement_link_text := "" }} {{ with index $announcement_link "text" }}{{ $announcement_link_text = strings.TrimSpace (printf "%v" .) }}{{ end }} {{ $announcement_link_url := "" }} {{ with index $announcement_link "url" }}{{ $announcement_link_url = strings.TrimSpace (printf "%v" .) }}{{ end }} {{ $primary_action := index $content "primary_action" }} {{ if not (reflect.IsMap $primary_action) }}{{ $primary_action = dict }}{{ end }} {{ $primary_text := "" }} {{ with index $primary_action "text" }}{{ $primary_text = strings.TrimSpace (printf "%v" .) }}{{ end }} {{ $primary_url := "" }} {{ with index $primary_action "url" }}{{ $primary_url = strings.TrimSpace (printf "%v" .) }}{{ end }} {{ $primary_icon := "" }} {{ with index $primary_action "icon" }}{{ $primary_icon = printf "%v" . }}{{ end }} {{ $secondary_action := index $content "secondary_action" }} {{ if not (reflect.IsMap $secondary_action) }}{{ $secondary_action = dict }}{{ end }} {{ $secondary_text := "" }} {{ with index $secondary_action "text" }}{{ $secondary_text = strings.TrimSpace (printf "%v" .) }}{{ end }} {{ $secondary_url := "" }} {{ with index $secondary_action "url" }}{{ $secondary_url = strings.TrimSpace (printf "%v" .) }}{{ end }}
{{ printf "%v" . | $page.RenderString | emojify }}
{{end}} {{ if and $primary_url $primary_text }} {{ $link := $primary_url }} {{ $scheme := (urls.Parse $link).Scheme }} {{ $target := "" }} {{ if not $scheme }} {{/* Check if it's a hash fragment (page anchor) */}} {{ if hasPrefix $link "#" }} {{/* Keep hash fragments as-is */}} {{ $link = $link }} {{ else }} {{/* Apply relLangURL for relative paths */}} {{ $link = $link | relLangURL }} {{ end }} {{ else if in (slice "http" "https") $scheme }} {{ $target = "target=\"_blank\" rel=\"noopener\"" }} {{ end }}