@model SectionView @{ var projects = Model.Section; var edit = Model.EditMode; } @functions { // Titel, Beschreibung, Detailbloecke und Links -- identisch fuer schmale und breite Karten. async Task RenderCardBody(ProjectItem project, bool edit) {

@project.Title

@if (edit) { @project.DescriptionLead } else if (!string.IsNullOrWhiteSpace(project.DescriptionLead)) { @project.DescriptionLead@: }

@foreach (var detail in project.Details) { @if (edit) {

@detail.Heading

@detail.Text

} else {

@detail.Heading

@detail.Text

} } @if (edit) { }
@if (edit) {
@foreach (var link in project.Links) { @link.Text }
} else if (project.Links.Count > 0) {
@for (var i = 0; i < project.Links.Count; i++) { var link = project.Links[i]; @link.Text }
} } }
@projects.Kicker

@projects.TitleHighlight

@{ // Schmale Karten stehen zu zweit in einer Reihe, breite Karten je allein. var index = 0; } @while (index < projects.Items.Count) { var project = projects.Items[index]; if (project.Wide) {
@project.ImageAlt
@{ await RenderCardBody(project, edit); }
@if (edit) { }
index++; } else { var pair = projects.Items.Skip(index).TakeWhile(p => !p.Wide).Take(2).ToList();
@foreach (var narrow in pair) {
@narrow.ImageAlt
@{ await RenderCardBody(narrow, edit); }
@if (edit) { }
}
index += pair.Count; } } @if (edit) { }