|
99 | 99 | {{ with index . "publications" }}{{ $publications = strings.TrimSpace (printf "%v" .) }}{{ end }} |
100 | 100 | {{ with index . "funding" }}{{ $funding = strings.TrimSpace (printf "%v" .) }}{{ end }} |
101 | 101 |
|
| 102 | + {{/* Generic metrics array: [{ icon, value, label }, ...] β first 3 rendered */}} |
| 103 | + {{ $metrics := slice }} |
| 104 | + {{ $metrics_raw := index . "metrics" }} |
| 105 | + {{ if reflect.IsSlice $metrics_raw }} |
| 106 | + {{ range $metrics_raw }} |
| 107 | + {{ if reflect.IsMap . }} |
| 108 | + {{ $m_icon := "" }} |
| 109 | + {{ $m_value := "" }} |
| 110 | + {{ $m_label := "" }} |
| 111 | + {{ with index . "icon" }}{{ $m_icon = printf "%v" . }}{{ end }} |
| 112 | + {{ with index . "value" }}{{ $m_value = strings.TrimSpace (printf "%v" .) }}{{ end }} |
| 113 | + {{ with index . "label" }}{{ $m_label = strings.TrimSpace (printf "%v" .) }}{{ end }} |
| 114 | + {{ if or $m_value $m_label }} |
| 115 | + {{ $metrics = $metrics | append (dict "icon" $m_icon "value" $m_value "label" $m_label) }} |
| 116 | + {{ end }} |
| 117 | + {{ end }} |
| 118 | + {{ end }} |
| 119 | + {{ end }} |
| 120 | + {{/* Backcompat: synthesise from legacy team_size / publications / funding when `metrics` not provided */}} |
| 121 | + {{ if not $metrics }} |
| 122 | + {{ if $team_size }} |
| 123 | + {{ $metrics = $metrics | append (dict "icon" "hero/user-group" "value" (replaceRE " researchers" "" $team_size) "label" "team") }} |
| 124 | + {{ end }} |
| 125 | + {{ if $publications }} |
| 126 | + {{ $metrics = $metrics | append (dict "icon" "hero/document-text" "value" (replaceRE " papers" "" $publications) "label" "papers") }} |
| 127 | + {{ end }} |
| 128 | + {{ if $funding }} |
| 129 | + {{ $metrics = $metrics | append (dict "icon" "hero/currency-dollar" "value" $funding "label" "funding") }} |
| 130 | + {{ end }} |
| 131 | + {{ end }} |
| 132 | + |
102 | 133 | {{ $cta_raw := index . "cta" }} |
103 | 134 | {{ if reflect.IsMap $cta_raw }} |
104 | 135 | {{ with index $cta_raw "url" }}{{ $cta_url = strings.TrimSpace (printf "%v" .) }}{{ end }} |
|
107 | 138 | {{ end }} |
108 | 139 |
|
109 | 140 | {{ if or $name $description }} |
110 | | - {{ $items = $items | append (dict "name" $name "description" $description "icon" $icon "image" $image "gradient" $gradient "url" $url "status" $status "topics" $topics "team_size" $team_size "publications" $publications "funding" $funding "cta" (dict "url" $cta_url "text" $cta_text "icon" $cta_icon)) }} |
| 141 | + {{ $items = $items | append (dict "name" $name "description" $description "icon" $icon "image" $image "gradient" $gradient "url" $url "status" $status "topics" $topics "metrics" $metrics "team_size" $team_size "publications" $publications "funding" $funding "cta" (dict "url" $cta_url "text" $cta_text "icon" $cta_icon)) }} |
111 | 142 | {{ end }} |
112 | 143 | {{ end }} |
113 | 144 | {{ end }} |
@@ -158,9 +189,7 @@ <h2 class="text-3xl sm:text-4xl lg:text-5xl font-bold text-gray-900 dark:text-wh |
158 | 189 | {{ $item_url := index $item "url" }} |
159 | 190 | {{ $status := index $item "status" }} |
160 | 191 | {{ $topics := index $item "topics" }} |
161 | | - {{ $team_size := index $item "team_size" }} |
162 | | - {{ $publications := index $item "publications" }} |
163 | | - {{ $funding := index $item "funding" }} |
| 192 | + {{ $metrics := index $item "metrics" }} |
164 | 193 | {{ $item_cta := index $item "cta" }} |
165 | 194 | {{ $item_cta_url := "" }} |
166 | 195 | {{ $item_cta_text := "" }} |
@@ -313,28 +342,16 @@ <h3 class="text-xl font-bold text-gray-900 dark:text-white mb-3"> |
313 | 342 |
|
314 | 343 | {{/* Footer Section - Always at bottom */}} |
315 | 344 | <div class="mt-auto"> |
316 | | - {{/* Stats/Metrics */}} |
317 | | - {{ if or $team_size $publications $funding }} |
| 345 | + {{/* Stats/Metrics β generic icon/value/label, max 3 */}} |
| 346 | + {{ with $metrics }} |
318 | 347 | <div class="grid grid-cols-3 gap-3 pt-4 border-t border-gray-200 dark:border-gray-700 mb-4"> |
319 | | - {{ with $team_size }} |
320 | | - <div class="flex flex-col items-center text-center text-gray-500 dark:text-gray-400"> |
321 | | - {{ partial "functions/get_icon" (dict "name" "hero/user-group" "attributes" "class=\"w-4 h-4 mx-auto mb-1\"") }} |
322 | | - <span class="text-xs leading-tight">{{ . | replaceRE " researchers" "" }}</span> |
323 | | - <span class="text-xs text-gray-400">team</span> |
324 | | - </div> |
325 | | - {{ end }} |
326 | | - {{ with $publications }} |
327 | | - <div class="flex flex-col items-center text-center text-gray-500 dark:text-gray-400"> |
328 | | - {{ partial "functions/get_icon" (dict "name" "hero/document-text" "attributes" "class=\"w-4 h-4 mx-auto mb-1\"") }} |
329 | | - <span class="text-xs leading-tight">{{ . | replaceRE " papers" "" }}</span> |
330 | | - <span class="text-xs text-gray-400">papers</span> |
331 | | - </div> |
332 | | - {{ end }} |
333 | | - {{ with $funding }} |
| 348 | + {{ range first 3 . }} |
334 | 349 | <div class="flex flex-col items-center text-center text-gray-500 dark:text-gray-400"> |
335 | | - {{ partial "functions/get_icon" (dict "name" "hero/currency-dollar" "attributes" "class=\"w-4 h-4 mx-auto mb-1\"") }} |
336 | | - <span class="text-xs leading-tight">{{ . }}</span> |
337 | | - <span class="text-xs text-gray-400">funding</span> |
| 350 | + {{ with index . "icon" }} |
| 351 | + {{ partial "functions/get_icon" (dict "name" . "attributes" "class=\"w-4 h-4 mx-auto mb-1\"") }} |
| 352 | + {{ end }} |
| 353 | + {{ with index . "value" }}<span class="text-xs leading-tight">{{ . }}</span>{{ end }} |
| 354 | + {{ with index . "label" }}<span class="text-xs text-gray-400">{{ . }}</span>{{ end }} |
338 | 355 | </div> |
339 | 356 | {{ end }} |
340 | 357 | </div> |
|
0 commit comments