{{/* Title section rendering for embed cards Parameters: - hb_id: Hugo Blox unique identifier - customTitle: user-provided title override - embedData: data fetched from API - customUrl: custom URL if provided - resource: platform resource identifier - type: resource type - platform: platform name - config: platform configuration */}} {{- $hb_id := .hb_id -}} {{- $customTitle := .customTitle -}} {{- $embedData := .embedData -}} {{- $customUrl := .customUrl -}} {{- $resource := .resource -}} {{- $type := .type -}} {{- $platform := .platform -}} {{- $config := .config -}}

{{- if $customTitle -}} {{ $customTitle | emojify }} {{- else if and $embedData $config.titleField -}} {{ index $embedData $config.titleField | emojify }} {{- else if and $embedData $embedData.name -}} {{ $embedData.name | emojify }} {{- else if and $embedData $embedData.id -}} {{ $embedData.id | emojify }} {{- else if $customUrl -}} {{- $parsed := urls.Parse $customUrl -}} {{ $parsed.Host | emojify }} {{- else if $resource -}} {{- if eq $platform "github" -}} {{/* For GitHub, show just the repo name, not the full "owner/repo" */}} {{- $parts := split $resource "/" -}} {{- if gt (len $parts) 1 -}} {{ index $parts 1 | emojify }} {{- else -}} {{ $resource | emojify }} {{- end -}} {{- else -}} {{ $resource | emojify }} {{- end -}} {{- else -}} Embedded Resource {{- end -}}

{{/* Resource type and subtype indicator */}} {{- $showTypeIndicator := false -}} {{- $typeText := "" -}} {{- $typeColor := $config.typeColor | default "zinc-500" -}} {{/* Always show type indicator for GitHub repos with data */}} {{- if and (eq $platform "github") $embedData $config.ownerField -}} {{- $showTypeIndicator = true -}} {{- end -}} {{/* Force metadata line for custom embeds to ensure proper alignment */}} {{- if eq $platform "custom" -}} {{- $showTypeIndicator = true -}} {{- end -}} {{- if $type -}} {{- $showTypeIndicator = true -}} {{- if and $embedData $config.subtypeField -}} {{- if $config.subtypeIndex -}} {{- $subtypes := index $embedData $config.subtypeField -}} {{- if $subtypes -}} {{- $typeText = index $subtypes $config.subtypeIndex -}} {{- else -}} {{- $typeText = $type -}} {{- end -}} {{- else -}} {{- $typeText = index $embedData $config.subtypeField | default $type -}} {{- end -}} {{- else -}} {{- $typeText = $type -}} {{- end -}} {{- else if and $embedData $config.subtypeField -}} {{- $showTypeIndicator = true -}} {{- if $config.subtypeIndex -}} {{- $subtypes := index $embedData $config.subtypeField -}} {{- if $subtypes -}} {{- $typeText = index $subtypes $config.subtypeIndex -}} {{- end -}} {{- else -}} {{- $typeText = index $embedData $config.subtypeField -}} {{- end -}} {{- end -}} {{- if $showTypeIndicator -}}
{{/* GitHub repos: Show owner prominently, then language */}} {{- if eq $platform "github" -}} {{- $owner := "" -}} {{/* Get owner from API data if available */}} {{- if $embedData -}} {{- if eq $config.ownerField "owner.login" -}} {{/* Handle nested GitHub API structure: embedData.owner.login */}} {{- $ownerObj := index $embedData "owner" -}} {{- if $ownerObj -}} {{- $owner = index $ownerObj "login" -}} {{- end -}} {{- else if $config.ownerField -}} {{/* Handle simple field access */}} {{- $owner = index $embedData $config.ownerField -}} {{- end -}} {{- end -}} {{/* Fallback: extract owner from resource string (e.g., "HugoBlox/kit" -> "HugoBlox") */}} {{- if and (not $owner) $resource -}} {{- $parts := split $resource "/" -}} {{- if gt (len $parts) 0 -}} {{- $owner = index $parts 0 -}} {{- end -}} {{- end -}} {{- if $owner -}} by {{ $owner | emojify }} {{- if $typeText -}} • {{ $typeText | emojify }} {{- end -}} {{- else if $typeText -}} {{/* No owner, just show type */}} {{ $typeText | emojify }} {{- end -}} {{- else if eq $platform "custom" -}} {{/* Custom embeds: Show domain or minimal placeholder for consistent alignment */}} {{- if $customUrl -}} {{- $parsed := urls.Parse $customUrl -}} {{- $domain := $parsed.Host -}} {{ $domain | emojify }} {{- else -}} {{/* Minimal placeholder to maintain visual spacing */}} external resource {{- end -}} {{- else -}} {{/* Other platforms: Show type with indicator */}} {{- if $typeText -}} {{ $typeText | emojify }} {{- else -}} {{/* Minimal placeholder for consistent spacing */}} platform resource {{- end -}} {{- end -}}
{{- end -}}