Skip to content

Commit

Permalink
Sort post archive
Browse files Browse the repository at this point in the history
  • Loading branch information
jbreckmckye committed Dec 17, 2017
1 parent 88924d4 commit 7273759
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions layout/partials/post-list.ejs
Expand Up @@ -5,10 +5,14 @@

<div id="blog-archives" class="category">
<%
const postViews = listPosts.reduce((acc, model)=> {
const sorted = listPosts.data.sort((a, b)=> {
return b.date.unix() - a.date.unix();
});
const postViews = sorted.reduce((acc, model)=> {
const entry = Object.assign(model, {
// only show year if this is first entry in list with that yearstamp
displayYear : !acc.find(_ => _.year === model.year),
displayYear : !acc.find(_ => _.date.year() === model.date.year()),
title: model.title || 'Untitled',
monthText: model.date.format('MMM'),
dayText: model.date.format('DD'),
Expand Down Expand Up @@ -51,4 +55,4 @@
<% }); %>

</div>
</article>
</article>

0 comments on commit 7273759

Please sign in to comment.