{{ $editorials := where (where $.Site.Pages "Section" "editorials" ) "Kind" "page" }} {{ $currentPage := path.Split (path.Clean .RelPermalink) }} {{ $displayedInHome := .IsHome }} {{ $isSingleEditorialPage := and (eq $currentPage.Dir "/editorials/") ($currentPage.File) }} {{ $editorials_to_show := slice }} {{/* Compile list of editorial to show depending upon the page */}} {{ if $displayedInHome }} {{ $editorials_to_show = $editorials_to_show | append (first 3 $editorials) }} {{ else if $isSingleEditorialPage }} {{ $editorials_to_show = $editorials_to_show | append (first 4 (.Scratch.Get "editorials_list")) }} {{ else if strings.HasSuffix $currentPage.Dir "/topics/" }} {{ range $editorials }} {{if in (apply .Params.editorials_topics "urlize" ".") $currentPage.File }} {{ $editorials_to_show = $editorials_to_show | append . }} {{ end }} {{ end }} {{ if strings.HasPrefix $currentPage.Dir "/topics/" }} {{ $editorials_to_show = first 3 $editorials_to_show }} {{ end }} {{ else if strings.HasSuffix $currentPage.Dir "/authors/" }} {{ range $editorials }} {{if in (apply .Params.editorials_authors "urlize" ".") $currentPage.File }} {{ $editorials_to_show = $editorials_to_show | append . }} {{ end }} {{ end }} {{ else }} {{ $editorials_to_show = $editorials_to_show | append $editorials }} {{ end }}