<% if (home === true) { %>
  <% if (theme.home_categories?.enable) { %>
    <div class="post-categories-wrapper" data-aos="<%= theme.animation.options.home.post %>">
      <% for (let content of theme.home_categories.content) { %>
        <% if (content.categories) { %>
        <div class="post-categories-wrap">
          <% let c = parseHomeCategories(content.categories); %>
          <a class="post-link" href="<%= url_for_lang(c.url, {relative: false}) %>" aria-label=""></a>
          <div class="post-categories-cover">
            <% if (content.cover) { %>
              <img data-src="<%- url_for(content.cover, {relative: false}) %>" data-sizes="auto" alt="<%= c.name %>" class="lazyload">
            <% } else { %>
              <% let cover = randomCover(); %>
              <% if (cover) { %>
                <img data-src="<%= cover %>" data-sizes="auto" alt="<%= c.name %>" class="lazyload">
              <% } else { %>
                <img data-src="<%- url_for(theme.banner, {relative: false}) %>" data-sizes="auto" alt="<%= c.name %>" class="lazyload">
              <% } %>
            <% } %>
            <h2><%= c.name %></h2>
            <h3><%= _p('home_categories.count', c.count) %></h3>
          </div>
        </div>
        <% } %>
      <% } %>
    </div>
  <% } %>
  <% if (page.lang) { %>
    <% let i = 0; %>
    <% for (const post of get_posts_by_lang(page.posts, page.lang)) { %>
      <%- partial('post', {post: post, even: i % 2 === 0}) %>
      <% i++; %>
    <% } %>
  <% } else { %>
    <% page.posts.forEach((post, i) => { %>
      <%- partial('post', {post: post, even: i % 2 === 0}) %>
    <% }) %>
  <% } %>
<% } else { %>
<div class="archives-outer-wrap" data-aos="<%= theme.animation.options.archive.whole %>">
  <% if (theme.only_show_capsule_in_index) { %>
    <% if (page.current === 1) { %>
      <%- partial_lang('post/archives', null, { cache: !config.relative_link, lang: page.lang }) %>
    <% } %>
  <% } else { %>
    <%- partial_lang('post/archives', null, { cache: !config.relative_link, lang: page.lang }) %>
  <% } %>
  <% if (page.lang) { %>
    <% const posts = get_posts_by_lang(page.posts, page.lang); %>
    <% var last; %>
    <% posts.forEach((post, i) => { %>
      <% var year = post.date.year(); %>
      <% if (last != year) { %>
        <% if (last != null) { %>
          </section>
        <% } %>
        <% last = year; %>
        <section class="archives-wrap" data-aos="<%= theme.animation.options.archive.section %>">
          <div class="archive-year-wrap">
            <a href="<%- url_for_lang(config.archive_dir + '/' + year) %>" class="archive-year"><%= year %></a>
          </div>
          <ul>
            <% } %>
            <%- partial('archive-post', {post: post}) %>
            <% }) %>
            <% if (page.posts.length) { %>
          </ul>
        </section>
    <% } %>
  <% } else { %>
    <% var last; %>
    <% page.posts.each((post, i) => { %>
      <% var year = post.date.year(); %>
      <% if (last != year) { %>
        <% if (last != null) { %>
          </section>
        <% } %>
        <% last = year; %>
        <section class="archives-wrap" data-aos="<%= theme.animation.options.archive.section %>">
          <div class="archive-year-wrap">
            <a href="<%- url_for_lang(config.archive_dir + '/' + year) %>" class="archive-year"><%= year %></a>
          </div>
          <ul>
            <% } %>
            <%- partial('archive-post', {post: post}) %>
            <% }) %>
            <% if (page.posts.length) { %>
          </ul>
        </section>
    <% } %>
  <% } %>
  </div>
<% } %>
<% if (page.total > 1) { %>
  <nav id="page-nav" data-aos="<%= theme.animation.options.archive.nav %>">
    <% let prev_text = "&laquo; " + __('prev');let next_text = __('next') + " &raquo;" %>
    <%- paginator({
          prev_text: prev_text,
          next_text: next_text,
          escape: false
      }) %>
  </nav>
<% } %>
