{{ $a := . }} {{ $pieces := LookupPieces $a }} {{ if ne (len $pieces) 0 }}

Beiträge

{{- /* Group pieces by title and work reference */ -}} {{- $groupedPieces := dict -}} {{- range $_, $p := SortPiecesByDate $pieces -}} {{- $groupKey := "" -}} {{- if $p.Item.Title -}} {{- $groupKey = index $p.Item.Title 0 -}} {{- else if $p.Item.WorkRefs -}} {{- $work := GetWork (index $p.Item.WorkRefs 0).Ref -}} {{- if $work.PreferredTitle -}} {{- $groupKey = $work.PreferredTitle -}} {{- else if $work.Citation.Title -}} {{- $groupKey = $work.Citation.Title -}} {{- end -}} {{- else if $p.Item.Incipit -}} {{- $groupKey = index $p.Item.Incipit 0 -}} {{- else -}} {{- $groupKey = printf "untitled-%s" $p.Item.ID -}} {{- end -}} {{- $existing := index $groupedPieces $groupKey -}} {{- if $existing -}} {{- $groupedPieces = merge $groupedPieces (dict $groupKey (append $existing $p)) -}} {{- else -}} {{- $groupedPieces = merge $groupedPieces (dict $groupKey (slice $p)) -}} {{- end -}} {{- end -}}
{{- /* Display grouped pieces */ -}} {{- range $groupKey, $groupedItems := $groupedPieces -}}
{{- /* Use first piece for display text */ -}} {{ template "_piece_summary" (dict "Piece" (index $groupedItems 0).Item "CurrentActorID" $a.ID) }} {{- /* Show all citations from all pieces in this group inline with commas */ -}} {{ " " }}{{- range $groupIndex, $groupItem := $groupedItems -}} {{- range $issueIndex, $issue := $groupItem.Item.IssueRefs -}} {{- if or (gt $groupIndex 0) (gt $issueIndex 0) }}, {{ end -}} {{- template "_citation" $issue -}}{{- end -}} {{- end -}} {{- /* Add "Ganzer Beitrag" link if piece spans multiple issues */ -}} {{- $firstGroupItem := index $groupedItems 0 -}} {{- if gt (len $firstGroupItem.Item.IssueRefs) 1 -}} {{ " " }} {{- end }}
{{- end -}}
{{ end }}