<%
if(pagination) {
page.posts.each(function(post) {
%>
<%-partial('archive-post', { post: post }) %>
<%
})
} else {
let lastYear, lastMonth;
let currentPosts = [];
site.posts.each(function(post) {
if((post.date.year() == page.year || !page.year) && (post.date.month()+1 == page.month || !page.month)) {
currentPosts.push(post)
}
})
currentPosts.sort(function(a, b){ return b.date - a.date;});
currentPosts.forEach(function(post) {
if(post.date.year() !== lastYear || post.date.month()+1 !== lastMonth) {
if(lastYear && lastMonth) { %> <% }
%>
<%
}
%>
<% if (pagination && page.total >= 1){ %>
<% } %>