Group list by class

This commit is contained in:
Christian Wolf 2025-01-20 13:51:21 +01:00
parent e3549c3ff4
commit fd8cb30b4a

View File

@ -3,6 +3,9 @@
{{- $list = sort $list "start" -}}
{{- $list = sort $list "class" -}}
{{- $list = sort $list "title" -}}
{{- $cals := apply $list "index" "." "class" -}}
{{- $cals = uniq $cals -}}
{{ warnf "%s" $cals}}
<table>
<thead>
<tr>
@ -39,3 +42,42 @@
{{- end}}
</tbody>
</table>
{{ range $cals }}
{{- $class := . -}}
<h2>Class {{ with . }}{{ . }}{{else}}<i>nil</i>{{end}}</h2>
<table>
<thead>
<tr>
<th>Gruppe</th>
<th>Jahrgang</th>
<th>Tag</th>
<th>Zeit</th>
<th>Ort</th>
</tr>
</thead>
<tbody>
{{ range $list -}}
{{- if ne .class $class }}{{ continue }}{{ end }}
<tr>
<td>
{{ .title }}{{ with .subtitle }} - {{ . }}{{ end }}
{{ if (.extern | default false) }}<i>(ext.)</i>{{ end }}
</td>
<td>{{ with .age }}{{ . }}{{ end }}</td>
<td>{{ index site.Data.days .day }}</td>
<td>
{{- $startTimeStr := printf "2025-01-02T%s:00" .start -}}
{{- $startTime := time.AsTime $startTimeStr -}}
{{- $duration := time.Duration "minute" .duration -}}
{{- $endTime := $startTime.Add $duration}}
{{/* warnf "Start %s, duration %s, %s" $startTime $duration $endTime */}}
{{- $startTime.Format "15:04"}} - {{ $endTime.Format "15:04" }}
</td>
<td>{{ .room }}</td>
</tr>
{{- end}}
</tbody>
</table>
{{ end }}