{{/* Hugo Blox: Dev 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 }} {{/* Enable animations if typewriter or scroll animations are configured */}} {{ $typewriter := index $content "typewriter" }} {{ if not (reflect.IsMap $typewriter) }}{{ $typewriter = dict }}{{ end }} {{ $typewriter_enabled := partial "functions/coerce_bool" (dict "value" (index $typewriter "enable") "default" false) }} {{ $animations_enabled := partial "functions/coerce_bool" (dict "value" (index $design "animations") "default" false) }} {{ $has_animations := or $typewriter_enabled $animations_enabled }} {{ if $has_animations }} {{ $page.Store.Set "has_animations" true }} {{ $page.Store.Set "has_alpine" true }} {{ end }} {{/* Get author data from YAML */}} {{ $username := "me" }} {{ $username_raw := index $content "username" }} {{ if eq (printf "%T" $username_raw) "string" }} {{ $username = strings.TrimSpace $username_raw }} {{ end }} {{ $author := partial "functions/get_author_profile" $username }} {{/* Get avatar */}} {{ $avatar := "" }} {{ $avatar_shape := "circle" }} {{ $avatar_shape_raw := index $design "avatar_shape" }} {{ if eq (printf "%T" $avatar_shape_raw) "string" }} {{ $avatar_shape = lower (strings.TrimSpace $avatar_shape_raw) }} {{ end }} {{ with $author.avatar }} {{ $avatar = .Fill "300x300 webp Center" }} {{ end }} {{/* Layout style */}} {{ $style := "centered" }} {{ $style_raw := index $design "style" }} {{ if eq (printf "%T" $style_raw) "string" }} {{ $style_candidate := lower (strings.TrimSpace $style_raw) }} {{ if in (slice "centered" "split") $style_candidate }} {{ $style = $style_candidate }} {{ end }} {{ end }} {{ $show_status := partial "functions/coerce_bool" (dict "value" (index $content "show_status") "default" false) }} {{ $show_scroll := partial "functions/coerce_bool" (dict "value" (index $content "show_scroll_indicator") "default" false) }} {{ $scroll_target := "#projects" }} {{ $scroll_target_raw := index $content "scroll_target" }} {{ if eq (printf "%T" $scroll_target_raw) "string" }} {{ $scroll_target = strings.TrimSpace $scroll_target_raw }} {{ end }} {{ if not $scroll_target }}{{ $scroll_target = "#projects" }}{{ end }} {{ $greeting := "" }} {{ $greeting_raw := index $content "greeting" }} {{ if eq (printf "%T" $greeting_raw) "string" }}{{ $greeting = $greeting_raw }}{{ end }} {{ $name_prefix := "" }} {{ $name_prefix_raw := index $content "name_prefix" }} {{ if eq (printf "%T" $name_prefix_raw) "string" }}{{ $name_prefix = $name_prefix_raw }}{{ end }} {{ $title_override := "" }} {{ $title_raw := index $content "title" }} {{ if eq (printf "%T" $title_raw) "string" }}{{ $title_override = strings.TrimSpace $title_raw }}{{ end }} {{ $tagline := "" }} {{ $tagline_raw := index $content "tagline" }} {{ if eq (printf "%T" $tagline_raw) "string" }}{{ $tagline = $tagline_raw }}{{ end }} {{ $bio_override := "" }} {{ $bio_raw := index $content "bio" }} {{ if eq (printf "%T" $bio_raw) "string" }}{{ $bio_override = $bio_raw }}{{ end }} {{ $role := $author.role | default $tagline }} {{ $bio := $author.bio | default $bio_override }} {{ $typewriter_strings := slice }} {{ $strings_raw := index $typewriter "strings" }} {{ if reflect.IsSlice $strings_raw }} {{ range $strings_raw }} {{ $val := strings.TrimSpace (printf "%v" .) }} {{ if $val }}{{ $typewriter_strings = $typewriter_strings | append $val }}{{ end }} {{ end }} {{ else if eq (printf "%T" $strings_raw) "string" }} {{ $val := strings.TrimSpace $strings_raw }} {{ if $val }}{{ $typewriter_strings = slice $val }}{{ end }} {{ end }} {{ $typewriter_prefix := "" }} {{ $typewriter_prefix_raw := index $typewriter "prefix" }} {{ if eq (printf "%T" $typewriter_prefix_raw) "string" }}{{ $typewriter_prefix = $typewriter_prefix_raw }}{{ end }} {{ $type_speed := partial "functions/coerce_int" (dict "value" (index $typewriter "type_speed") "default" 80 "min" 10 "max" 500) }} {{ $delete_speed := partial "functions/coerce_int" (dict "value" (index $typewriter "delete_speed") "default" 50 "min" 10 "max" 500) }} {{ $pause_time := partial "functions/coerce_int" (dict "value" (index $typewriter "pause_time") "default" 2000 "min" 200 "max" 10000) }} {{ $links_raw := $author.links | default (index $content "links") }} {{ $links := slice }} {{ if reflect.IsSlice $links_raw }} {{ range $links_raw }} {{ $url := "" }} {{ $icon := "hero/link" }} {{ $label := "" }} {{ if reflect.IsMap . }} {{ $url_raw := index . "url" | default (index . "link") }} {{ if eq (printf "%T" $url_raw) "string" }}{{ $url = strings.TrimSpace $url_raw }}{{ end }} {{ $icon_raw := index . "icon" }} {{ if eq (printf "%T" $icon_raw) "string" }}{{ $icon = $icon_raw }}{{ end }} {{ $label_raw := index . "label" | default (index . "name") }} {{ if eq (printf "%T" $label_raw) "string" }}{{ $label = $label_raw }}{{ end }} {{ else if eq (printf "%T" .) "string" }} {{ $url = strings.TrimSpace . }} {{ end }} {{ if $url }} {{ $links = $links | append (dict "url" $url "icon" $icon "label" $label) }} {{ end }} {{ end }} {{ else if eq (printf "%T" $links_raw) "string" }} {{ $url := strings.TrimSpace $links_raw }} {{ if $url }} {{ $links = slice (dict "url" $url "icon" "hero/link" "label" "") }} {{ end }} {{ end }} {{ $cta_buttons_raw := index $content "cta_buttons" }} {{ $cta_buttons := slice }} {{ if reflect.IsSlice $cta_buttons_raw }} {{ $cta_buttons = $cta_buttons_raw }} {{ else if and $cta_buttons_raw (reflect.IsMap $cta_buttons_raw) }} {{ $cta_buttons = slice $cta_buttons_raw }} {{ end }} {{ $status_icon := "" }} {{ $status := $author.status }} {{ if and $status (reflect.IsMap $status) }} {{ $status_icon_raw := index $status "icon" }} {{ if eq (printf "%T" $status_icon_raw) "string" }} {{ $status_icon = $status_icon_raw }} {{ end }} {{ end }}
{{ . }}
{{ end }} {{/* Name */}}{{ with $typewriter_prefix }}{{ . }} {{ end }}
{{ else if $role }}{{ $role | $page.RenderString }}
{{ end }} {{/* Bio */}} {{ with $bio }}{{ . | $page.RenderString }}
{{ end }} {{/* Social Links */}} {{ if gt (len $links) 0 }}{{ . }}
{{ end }} {{/* Name */}}{{ with $typewriter_prefix }}{{ . }} {{ end }}
{{ else if $role }}{{ $role | $page.RenderString }}
{{ end }} {{/* Bio */}} {{ with $bio }}{{ . | $page.RenderString }}
{{ end }} {{/* Social Links */}} {{ if gt (len $links) 0 }}