{{/* Prints the next 2 articles in the same section or, if less or 2 found, the first (and potentially second) of the section. @author @regisphilibert @mountainbug95 @context Type Page (.) @access public */}} {{/* declaring next empty slice */}} {{ $next := slice }} {{/* Checking if current article has a PrevInSection (Prev as we are ordering dsc here.) */}} {{ with .PrevInSection }} {{ $next = $next | append . }} {{/* Checking for that "next" article own "next" to fill the "second next" */}} {{ with .PrevInSection }} {{ $next = $next | append . }} {{ end }} {{ end }} {{/* If the number of found "next article" is less than two we need to find the first and potentially second article of the whole section and append them to our $next slice. */}} {{ $diff := sub 2 (len $next) }} {{ if $diff }} {{/* We use that diff number (if > 0) to grab the first x number of articles */}} {{ $articles := partialCached "func/GetArticles" . "articles"}} {{ $next = $next | append (first $diff $articles) }} {{ end }}