hackertours/layouts/_shortcodes/events.html
Vincent Mahnke 0a415a4958
feat: Takes over the 40C3 startpage's background and headings
Light green background (#dff0d4), which is also the text colour in the
dark scheme. Page titles and the site name are capitals like the
startpage's h1, and section headings are green boxes like its
"GET INFORMED", so the home page's 40C3 heading is now an h2.
The EH22 logo credit moves to the footer.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
2026-11-09 00:28:00 +01:00

75 lines
3.2 KiB
HTML
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

{{- /*
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 are in the footer (footer.html).
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 -}}
<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 }}
<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>
{{- end }}