<!DOCTYPE html>
<html
  xmlns:th="https://www.thymeleaf.org"
  th:replace="~{modules/layout :: html(title = |#{page.archives.title} - ${site.title}|, pageType = 'archive', terminalUserName = ${archives != null and archives.items != null and !#lists.isEmpty(archives.items) and archives.items[0].months != null and !#lists.isEmpty(archives.items[0].months) and archives.items[0].months[0].posts != null and !#lists.isEmpty(archives.items[0].months[0].posts) and archives.items[0].months[0].posts[0].owner != null and !#strings.isEmpty(archives.items[0].months[0].posts[0].owner.name) ? archives.items[0].months[0].posts[0].owner.name : 'admin'}, content = ~{::content})}"
>
  <th:block th:fragment="content">
    <section class="devcm-terminal-window devcm-archive-hero">
      <div class="devcm-window-titlebar">
        <span class="devcm-window-dot"></span>
        <span class="devcm-window-dot"></span>
        <span class="devcm-window-dot"></span>
      </div>
      <div class="devcm-hero">
        <div class="devcm-hero__copy">
          <div class="devcm-prompt-line">
            <span th:text="|${terminalUser}@devcm:~$|">admin@devcm:~$</span>
            <span th:text="#{devcm.archive.command}">archive --view posts</span>
          </div>
          <h1 class="devcm-hero__title" th:text="#{devcm.archive.title}">Archives</h1>
          <p class="devcm-hero__desc" th:text="#{devcm.archive.description}">Browse content by publish date.</p>
        </div>
      </div>
    </section>

    <section class="devcm-archive-table">
      <div class="devcm-archive-table__title" th:text="#{devcm.archive.tableTitle}">Archive list</div>
      <div class="devcm-archive-row devcm-archive-row--header">
        <span th:text="#{devcm.archive.columnTitle}">Title</span>
        <span th:text="#{devcm.archive.columnTags}">Tags</span>
        <span th:text="#{devcm.archive.columnDate}">Date</span>
      </div>
      <th:block th:each="archive : ${archives.items}">
        <th:block th:each="month : ${archive.months}">
          <div class="devcm-archive-row devcm-archive-row--month">
            <span>
              <span th:text="#{devcm.archive.group}">Archive group</span>
              (<span th:text="${#lists.size(month.posts)}">0</span>)
            </span>
          </div>
          <a class="devcm-archive-row" th:each="post : ${month.posts}" th:href="${post.status.permalink}">
            <span th:text="${post.spec.title}">文章标题</span>
            <span>
              <b th:each="tag : ${post.tags}" th:text="'#' + ${tag.spec.displayName} + ' '">#tag</b>
            </span>
            <span th:text="${#dates.format(post.spec.publishTime,'MM-dd')}">01-01</span>
          </a>
        </th:block>
      </th:block>
    </section>

    <div class="pagination" th:if="${archives.hasPrevious() || archives.hasNext()}">
      <div class="pagination__buttons">
        <span class="button previous" th:if="${archives.hasPrevious()}">
          <a th:href="@{${archives.prevUrl}}">
            <span class="button__icon"><&nbsp;</span>
            <span class="button__text" th:text="#{devcm.pagination.previous}">Previous</span>
          </a>
        </span>
        <span class="button next" th:if="${archives.hasNext()}">
          <a th:href="@{${archives.nextUrl}}">
            <span class="button__text" th:text="#{devcm.pagination.next}">Next</span>
            <span class="button__icon">&nbsp;></span>
          </a>
        </span>
      </div>
    </div>
  </th:block>
</html>
