<% if (page.year || page.month) { %>
	<%- partial('_partial/archive') %>
<% } else { %>
  <article id="archive-page" class="post article white-box">
    <section class='meta'>
      <h2 class="title">
        <a href="javascript:void(0)">
          Archives
        </a>
      </h2>
    </section>
    <section class="archive">
      <%
        const data = [];
        let length = 0;
        site.posts.sort('date', -1).forEach(function(post) {
          const year = date(post.date, 'YYYY');
          const lastData = data[length - 1];
          if(!lastData || lastData.year !== year) {
            length = data.push({
              year: year,
              posts: [post],
            });
          } else {
            lastData.posts.push(post);
          }
        });
        data.forEach(function(yearData) {
      %>
        <div class="archive-item archive-year mark">
          <a id="archive-year-<%= yearData.year %>" href='<%= url_for("/archives/" + yearData.year + "/") %>' >
            <%= yearData.year %>
            <span class="count">
              (<%= yearData.posts.length %>)
            </span>
          </a>
        </div>
        <% yearData.posts.forEach(function(post) { %>
          <div class="archive-item archive-post mark">
            <a href="<%= url_for(post.path) %>">
              <time><%= date(post.date, 'MM-DD') %></time>
              <span class="title"><span><%= post.title %></span></span>
            </a>
          </div>
        <% }); %>
      <% }); %>
    </section>
  </article>
<% } %>