{{/* Award badge — single source of truth for rendering an award entry. Args (dict): award Award entry (dict with name, level, issuer, date, note, url). Bare-string entries are coerced to {name: }. page Owning page (used to fall back issuer to publication, date to page date). variant Visual style — one of: "pill" horizontal pill (default; used in skim rows) "card-corner" absolute-positioned corner pill (for card/grid views) "row" full row with name + note (for metadata grid) "inline" compact inline marker for citations Falls back gracefully when fields are missing. */}} {{- $award := .award -}} {{- $page := .page -}} {{- $variant := .variant | default "pill" -}} {{/* Coerce bare-string entries to {name: ...} */}} {{- if not (reflect.IsMap $award) -}} {{- $award = dict "name" $award -}} {{- end -}} {{- $name := $award.name | default "" -}} {{- $level := $award.level | default "winner" -}} {{- $note := $award.note | default "" -}} {{- $url := $award.url | default "" -}} {{/* Issuer fallback: explicit → publication short_name → publication name → empty */}} {{- $issuer := $award.issuer | default "" -}} {{- if not $issuer -}} {{- with $page -}} {{- $pub := partial "functions/resolve_publication.html" . -}} {{- $issuer = $pub.short_name | default $pub.name | default "" -}} {{- end -}} {{- end -}} {{/* Date fallback: explicit → page date year */}} {{- $date := $award.date | default "" -}} {{- if not $date -}} {{- with $page -}} {{- with .Date -}}{{- $date = .Format "2006" -}}{{- end -}} {{- end -}} {{- end -}} {{/* Icon + colour token per level */}} {{- $icon := "trophy" -}} {{- $tone := "amber" -}} {{- if eq $level "winner" -}}{{- $icon = "trophy" -}}{{- $tone = "amber" -}} {{- else if eq $level "runner_up" -}}{{- $icon = "medal" -}}{{- $tone = "slate" -}} {{- else if eq $level "honorable_mention" -}}{{- $icon = "ribbon" -}}{{- $tone = "rose" -}} {{- else if eq $level "nominee" -}}{{- $icon = "star" -}}{{- $tone = "sky" -}} {{- else if eq $level "selected" -}}{{- $icon = "sparkles" -}}{{- $tone = "violet" -}} {{- else if eq $level "featured" -}}{{- $icon = "bookmark-star" -}}{{- $tone = "emerald" -}} {{- end -}} {{/* Tailwind class shards keyed by tone (full classes for the extractor) */}} {{- $bg := "" -}}{{- $text := "" -}}{{- $ring := "" -}} {{- if eq $tone "amber" -}} {{- $bg = "bg-amber-100 dark:bg-amber-900/40" -}} {{- $text = "text-amber-900 dark:text-amber-200" -}} {{- $ring = "ring-amber-500/30 dark:ring-amber-400/30" -}} {{- else if eq $tone "slate" -}} {{- $bg = "bg-slate-100 dark:bg-slate-800/60" -}} {{- $text = "text-slate-900 dark:text-slate-200" -}} {{- $ring = "ring-slate-500/30 dark:ring-slate-400/30" -}} {{- else if eq $tone "rose" -}} {{- $bg = "bg-rose-100 dark:bg-rose-900/40" -}} {{- $text = "text-rose-900 dark:text-rose-200" -}} {{- $ring = "ring-rose-500/30 dark:ring-rose-400/30" -}} {{- else if eq $tone "sky" -}} {{- $bg = "bg-sky-100 dark:bg-sky-900/40" -}} {{- $text = "text-sky-900 dark:text-sky-200" -}} {{- $ring = "ring-sky-500/30 dark:ring-sky-400/30" -}} {{- else if eq $tone "violet" -}} {{- $bg = "bg-violet-100 dark:bg-violet-900/40" -}} {{- $text = "text-violet-900 dark:text-violet-200" -}} {{- $ring = "ring-violet-500/30 dark:ring-violet-400/30" -}} {{- else if eq $tone "emerald" -}} {{- $bg = "bg-emerald-100 dark:bg-emerald-900/40" -}} {{- $text = "text-emerald-900 dark:text-emerald-200" -}} {{- $ring = "ring-emerald-500/30 dark:ring-emerald-400/30" -}} {{- end -}} {{/* Inline SVG icons (small, self-contained — no dependency on external icon system at render time) */}} {{- $svg := "" -}} {{- if eq $icon "trophy" -}} {{- $svg = `` -}} {{- else if eq $icon "medal" -}} {{- $svg = `` -}} {{- else if eq $icon "ribbon" -}} {{- $svg = `` -}} {{- else if eq $icon "star" -}} {{- $svg = `` -}} {{- else if eq $icon "sparkles" -}} {{- $svg = `` -}} {{- else if eq $icon "bookmark-star" -}} {{- $svg = `` -}} {{- end -}} {{/* Build subtitle: "Issuer · Year" or just whichever is present */}} {{- $subtitle := "" -}} {{- if and $issuer $date -}} {{- $subtitle = printf "%s · %s" $issuer $date -}} {{- else if $issuer -}} {{- $subtitle = $issuer -}} {{- else if $date -}} {{- $subtitle = $date -}} {{- end -}} {{- $tooltip := $name -}} {{- with $subtitle -}}{{- $tooltip = printf "%s — %s" $name . -}}{{- end -}} {{- if $name -}} {{- if eq $variant "pill" -}} {{- if $url -}} {{ $svg | safeHTML }} {{ $name }} {{- with $subtitle }}{{ end -}} {{- else -}} {{ $svg | safeHTML }} {{ $name }} {{- with $subtitle }}{{ end -}} {{- end -}} {{- else if eq $variant "card-corner" -}} {{- if $url -}} {{ $svg | safeHTML }} {{ $name }} {{- else -}} {{ $svg | safeHTML }} {{ $name }} {{- end -}} {{- else if eq $variant "inline" -}} {{- if $url -}} {{ $svg | safeHTML }} {{ $name }} {{- else -}} {{ $svg | safeHTML }} {{ $name }} {{- end -}} {{- else if eq $variant "row" -}}
{{ $svg | safeHTML }}
{{- if $url -}}{{ $name }} {{- else -}}{{ $name }}{{- end -}}
{{- with $subtitle -}}
{{ . }}
{{- end -}} {{- with $note -}}
{{ . | markdownify }}
{{- end -}}
{{- end -}} {{- end -}}