changes working
This commit is contained in:
@@ -0,0 +1,58 @@
|
||||
{{/*
|
||||
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 }}
|
||||
<section id="articleNext" class="section nartrow">
|
||||
<h3 class="footer-next-heading">More articles from {{ .Site.Title }}</h3>
|
||||
<div class="footer-spacer"></div>
|
||||
<div class="next-articles-grid" numberOfArticles={numberOfArticles}>
|
||||
<div class="post-row">
|
||||
{{ range $index, $article := $next }}
|
||||
<a href="{{ $article.RelPermalink }}" class="article-link"
|
||||
{{ if not $index}} id="article-link-bigger"{{ end }}>
|
||||
<div>
|
||||
<div class="image-container">
|
||||
<img src="{{ $article.Params.hero }}" class="article-image" />
|
||||
</div>
|
||||
<div>
|
||||
<h2 class="article-title">
|
||||
{{ $article.Params.title }}
|
||||
</h2>
|
||||
<p class="article-excerpt">
|
||||
{{ $article.Params.excerpt }}
|
||||
</p>
|
||||
<div class="article-metadata">
|
||||
{{ $article.Date | dateFormat "January 1, 2006" }}{{ with $article.Params.timeToRead }} · {{ $article.Params.timeToRead }} min read{{ end }}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</a>
|
||||
{{ end }}
|
||||
</div>
|
||||
</div>
|
||||
</section>
|
||||
Reference in New Issue
Block a user