<!DOCTYPE html>
<html
  xmlns:th="https://www.thymeleaf.org"
  th:replace="~{modules/layout :: html(title = |${post.spec.title} - ${site.title}|, pageType = 'post', terminalUserName = ${post != null and post.owner != null and !#strings.isEmpty(post.owner.name) ? post.owner.name : 'admin'}, content = ~{::content})}"
>
  <th:block th:fragment="content">
    <article class="devcm-editor-window devcm-article" x-data="postLineNum" x-init="init()">
      <div class="devcm-editor-tabs">
        <div
          class="devcm-editor-tab devcm-editor-tab--active"
          th:with="postTabBaseName=${!#strings.isEmpty(post.spec.slug) ? post.spec.slug : post.metadata.name},
            postTabName=${#strings.endsWith(postTabBaseName, '.md') ? postTabBaseName : postTabBaseName + '.md'},
            archiveActivityItem=${theme.config.activity.activity_items != null and !#lists.isEmpty(theme.config.activity.activity_items) ? theme.config.activity.activity_items.^[type == 'archive' or key == 'archive'] : null},
            postCloseHref=${!#strings.isEmpty(site.routes.archivesUri) ? site.routes.archivesUri : (archiveActivityItem != null and !#strings.isEmpty(archiveActivityItem.url) ? archiveActivityItem.url : (archiveActivityItem != null and !#strings.isEmpty(archiveActivityItem.href) ? archiveActivityItem.href : '/archives'))}"
        >
          <span th:text="${postTabName}">post</span>
          <a
            class="devcm-editor-tab__close"
            href="#"
            th:href="${postCloseHref}"
            th:aria-label="#{devcm.action.closePostTab}"
            th:title="#{devcm.action.closePostTab}"
            >×</a
          >
        </div>
      </div>

      <div class="post-body devcm-article-body">
        <div class="post-line-gutter"></div>
        <div class="post-content devcm-article-content">
          <div>
            <h1 class="devcm-article-title" th:text="'< ' + ${post.spec.title} + ' >'">Post Title</h1>
            <div class="devcm-article-meta">
              <span th:text="${#dates.format(post.spec.publishTime,'yyyy-MM-dd')}">publishTime</span>
              <span th:text="${post.owner.displayName}">Author</span>
              <a
                th:each="tag : ${post.tags}"
                th:href="${tag.status.permalink}"
                th:title="${tag.spec.displayName}"
                th:text="'#' + ${tag.spec.displayName}"
              >
                #Tag
              </a>
            </div>
            <div th:utext="${post.content.content}">Post Content</div>
          </div>
        </div>
      </div>
    </article>

    <section class="comment-wrap devcm-comments" x-data="themeComment()" x-init="init()" th:if="${haloCommentEnabled}">
      <div class="devcm-comment-titlebar">
        <span class="devcm-window-dot"></span>
        <span class="devcm-window-dot"></span>
        <span class="devcm-window-dot"></span>
        <strong th:text="#{devcm.comments.file}">comments.log</strong>
      </div>
      <div class="devcm-comment-body">
        <h2 th:text="#{devcm.comments.title}">## Comments</h2>
        <halo:comment group="content.halo.run" kind="Post" th:attr="name=${post.metadata.name}" />
      </div>
    </section>

    <nav class="pagination devcm-prev-next" th:with="postCursor=${postFinder.cursor(post.metadata?.name)}">
      <div class="pagination__buttons">
        <span th:if="${postCursor.hasPrevious()}" class="button previous">
          <a th:href="${postCursor.previous?.status?.permalink}">
            <span class="button__icon"><&nbsp;</span>
            <span class="button__text" th:text="${postCursor.previous?.spec?.title}">Previous</span>
          </a>
        </span>
        <span th:if="${postCursor.hasNext()}" class="button next">
          <a th:href="${postCursor.next?.status?.permalink}">
            <span class="button__text" th:text="${postCursor.next?.spec?.title}">Next</span>
            <span class="button__icon">&nbsp;></span>
          </a>
        </span>
      </div>
    </nav>
  </th:block>
</html>
