{{/* Hugo Blox: Hero */}} {{/* Documentation: https://hugoblox.com/blocks/ */}} {{/* License: https://github.com/HugoBlox/hugo-blox-builder/blob/main/LICENSE.md */}} {{/* Initialise */}} {{ $page := .wcPage }} {{ $block := .wcBlock }} {{ $bg := $block.design.background }} {{ if $block.content.image.filename }}
{{ end }} {{ with $block.content.title }}

{{ . | markdownify }}

{{ end }} {{ with $block.content.text }}
{{ . | $page.RenderString | emojify }}
{{ end }} {{/* Call-to-action link */}} {{ if $block.content.cta.url }} {{ $pack := or $block.content.cta.icon_pack "fas" }} {{ $pack_prefix := $pack }} {{ if in (slice "fab" "fas" "far" "fal") $pack }} {{ $pack_prefix = "fa" }} {{ end }} {{ $link := $block.content.cta.url }} {{ $scheme := (urls.Parse $link).Scheme }} {{ $target := "" }} {{ if not $scheme }} {{ $link = $link | relLangURL }} {{ else if in (slice "http" "https") $scheme }} {{ $target = "target=\"_blank\" rel=\"noopener\"" }} {{ end }}

{{ if $block.content.cta.icon }}{{end}}{{ $block.content.cta.label | markdownify | emojify | safeHTML }} {{/* Alternative Call-to-action link */}} {{ if $block.content.cta_alt.url }} {{ $link := $block.content.cta_alt.url }} {{ $scheme := (urls.Parse $link).Scheme }} {{ $target := "" }} {{ if not $scheme }} {{ $link = $link | relLangURL }} {{ else if in (slice "http" "https") $scheme }} {{ $target = "target=\"_blank\" rel=\"noopener\"" }} {{ end }} {{ $block.content.cta_alt.label | markdownify | emojify | safeHTML }} {{ end }}

{{ end }} {{/* Call-to-action note */}} {{ with $block.content.cta_note }}

{{ .label | markdownify | emojify | safeHTML }}

{{ end }} {{/* Hero image */}} {{ if $block.content.image.filename }}
{{- $image := resources.Get (path.Join "media" $block.content.image.filename) -}} {{ if $image }} {{ $isSVG := eq $image.MediaType.SubType "svg" }} {{ if $isSVG -}} {{ $block.Title }} {{- else }} {{ $legacy_img := $image.Resize "400x" }} {{ $img_src := "" }} {{ $img_src_set := slice }} {{ $widths := slice 1200 800 400 }} {{ range $widths }} {{ $src_link := ($image.Resize (printf "%dx" .)).RelPermalink }} {{ if eq $img_src "" }} {{ $img_src = $src_link }} {{ end }} {{ $img_src_set = $img_src_set | append (printf "%s %dw" $src_link .) }} {{ end }} {{ $img_src_set = delimit $img_src_set "," }} {{ $block.Title }} {{ end }} {{ end }}
{{ end }}