hexo-theme-stellar/layout/archive.ejs

44 lines
1.4 KiB
Plaintext
Executable File

<%
page.robots = 'noindex,follow';
if (page.menu_id == undefined) {
page.menu_id = 'post';
}
%>
<% if (page.posts && (is_category() || is_tag())) { %>
<%- partial('index') %>
<% } else { %>
<% page.title = __('btn.archives') + ' - ' + config.title; %>
<%- partial('_partial/main/navbar/list_post') %>
<div class='post-list'>
<% var years = []; %>
<% site.posts.sort('date', -1).each(function(post) { %>
<% post.year = date(post.date, 'YYYY'); %>
<% if (post.year && (years.includes(post.year) == false) && (post.title || post.date)) { %>
<% years.push(post.year); %>
<% } %>
<% }); %>
<% years.forEach((year, i) => { %>
<article class='<%- scrollreveal() %>' id='archive'>
<div class='archive-header h4'><%= year %></div>
<% site.posts.sort('date', -1).filter(function (post) { %>
<% post.year = date(post.date, 'YYYY'); %>
<% return post.year == year; %>
<% }).each(function(post) { %>
<div class='archive-list'>
<a class='post fs14' href="<%= url_for(post.link || post.path) %>">
<time><%= date(post.date, 'MM-DD') %></time>
<span>
<% if (post.title) { %>
<%- post.title %>
<% } else if (post.date) { %>
<%= date(post.date, config.date_format) %>
<% } %>
</span>
</a>
</div>
<% }); %>
</article>
<% }); %>
</div>
<% } %>