Replaces the line of links to previous events with cards after the 40C3 start page: each card has the event's logo (designs.events.ccc.de) in its heading bar, the motto, full name, dates and venue. 40C3 is greyed out as in progress; the other cards link to their tours. The events shortcode reads data/events.yaml; the README documents it. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
82 lines
3.5 KiB
HTML
82 lines
3.5 KiB
HTML
{{- /*
|
||
Event cards from data/events.yaml, after the cards on the 40C3 start page
|
||
(events.ccc.de/congress/2026/infos/startpage.html): the event's name and logo
|
||
(assets/img/events/<event>.svg) in a heading bar, its motto, full name, dates and venue below.
|
||
Cards link to the event's section; an event that is in progress, or has no section, gets a
|
||
greyed-out card without a link. Logo credits from the data file follow the cards.
|
||
|
||
Usage: {{< events >}}
|
||
*/ -}}
|
||
{{- $events := slice -}}
|
||
{{- with hugo.Data.events }}{{ with .events }}{{ $events = . }}{{ end }}{{ end -}}
|
||
{{- if not $events -}}
|
||
{{- warnidf "warning-events-empty" "events: no events in data/events.yaml: %s" .Position -}}
|
||
{{- else -}}
|
||
{{- $credits := slice -}}
|
||
<ul class="event-cards" role="list">
|
||
{{- range $events }}
|
||
{{- $name := .name | default (upper .event) }}
|
||
{{- $inProgress := eq .status "inprogress" }}
|
||
{{- $page := site.GetPage (printf "/%s" .event) }}
|
||
{{- if not (or $page $inProgress) }}{{ warnf "events: no section page for event %q" .event }}{{ end }}
|
||
{{- $link := and $page (not $inProgress) }}
|
||
{{- /* A title with one entry per language, or one for all. */}}
|
||
{{- $title := .title }}
|
||
{{- if reflect.IsMap $title }}{{ $title = index $title site.Language.Name | default (index $title "en") }}{{ end }}
|
||
{{- /* Date ranges as on the 40C3 start page: "27.–30. Dezember 2026", "27–30 December 2026". */}}
|
||
{{- $start := time.AsTime .start }}
|
||
{{- $end := time.AsTime (.end | default .start) }}
|
||
{{- $date := i18n "events_date" }}
|
||
{{- $when := $end | time.Format $date }}
|
||
{{- if ne $start.Year $end.Year }}
|
||
{{- $when = printf "%s – %s" ($start | time.Format $date) $when }}
|
||
{{- else if ne $start.Month $end.Month }}
|
||
{{- $when = printf "%s – %s" ($start | time.Format (i18n "events_date_day_month")) $when }}
|
||
{{- else if ne $start.Day $end.Day }}
|
||
{{- $when = printf "%s–%s" ($start | time.Format (i18n "events_date_day")) $when }}
|
||
{{- end }}
|
||
{{- /* The logo keeps its proportions (the SVG's viewBox) at the height set in CSS. */}}
|
||
{{- $logo := resources.Get (printf "img/events/%s.svg" .event) }}
|
||
{{- $ratio := slice 1 1 }}
|
||
{{- with $logo }}
|
||
{{- with findRESubmatch `viewBox="\s*[-\d.]+[\s,]+[-\d.]+[\s,]+([\d.]+)[\s,]+([\d.]+)\s*"` .Content 1 }}
|
||
{{- $ratio = slice (float (index . 0 1)) (float (index . 0 2)) }}
|
||
{{- end }}
|
||
{{- else }}
|
||
{{- warnf "events: no logo assets/img/events/%s.svg" .event }}
|
||
{{- end }}
|
||
{{- with .credit }}{{ $credits = $credits | append (dict "name" $name "credit" .) }}{{ end }}
|
||
<li class="event-cards__item">
|
||
{{- if $link }}
|
||
<a class="event-card" href="{{ $page.RelPermalink }}">
|
||
{{- else }}
|
||
<div class="event-card event-card--inactive">
|
||
{{- end }}
|
||
<div class="event-card__heading">
|
||
<h3 class="event-card__title">{{ $name }}</h3>
|
||
{{- with $logo }}
|
||
<span class="event-card__logo" style="--event-logo: url({{ .RelPermalink }}); aspect-ratio: {{ index $ratio 0 }} / {{ index $ratio 1 }}" aria-hidden="true"></span>
|
||
{{- end }}
|
||
</div>
|
||
<div class="event-card__body">
|
||
{{- with .motto }}
|
||
<p class="event-card__motto">{{ . }}</p>
|
||
{{- end }}
|
||
{{- with $title }}
|
||
<p class="event-card__meta">{{ . }}</p>
|
||
{{- end }}
|
||
<p class="event-card__meta">{{ $when }}{{ with .venue }}, {{ . }}{{ end }}</p>
|
||
{{- if $inProgress }}
|
||
<p class="event-card__status">{{ i18n "events_inprogress" }}</p>
|
||
{{- end }}
|
||
</div>
|
||
{{ if $link }}</a>{{ else }}</div>{{ end }}
|
||
</li>
|
||
{{- end }}
|
||
</ul>
|
||
{{- with $credits }}
|
||
<p class="event-cards__credits">
|
||
{{- range $index, $entry := . }}{{ if $index }} · {{ end }}{{ i18n "events_logo" (dict "Name" $entry.name) }}: {{ $.Page.RenderString $entry.credit }}{{ end -}}
|
||
</p>
|
||
{{- end }}
|
||
{{- end }}
|