<%
var getDate = function(article) {
return article.created_at !== article.updated_at ? article.updated_at : article.created_at;
}
var sortByDate = function(a, b) {
return new Date(getDate(b)) - new Date(getDate(a));
}
var getColumnClasses = function(columnNumber) {
var classNames = 'col-12';
if (columnNumber >= 2) classNames += ' md:col-6';
if (columnNumber >= 3) classNames += ' lg:col-4';
if (columnNumber >= 4) classNames += ' xl:col-3';
return classNames;
}
articles = articles
.filter(function(article) {
return article['label_names'] && article['label_names'].indexOf('new') !== -1;
})
.sort(sortByDate).slice(0, maxArticles);
%>
<% if (articles.length) { %>
What's new
<% articles.forEach(function(article) {
var section = sections.filter(function(section) {
return section.id === article['section_id'];
})[0] || null;
%>
<% }) %>
<% } %>