{{ define "main" }}

{{ $pages := .Pages }}
{{ $pages = (.Paginate $pages).Pages }}

<header>
  <div class="container">
    <h1>{{ .Title }}</h1>
    <p class="subtitle">
      <span class="count">{{ len .Pages }}</span> postagens encontradas.
    </p>
  </div>
</header>

<section>
  <div class="container">
    <section>
      <section>
        <div class="posts">
          {{ range $pages }}
          <div class="post">
            <a href="{{ .RelPermalink }}">
              <div class="post-row">
                <time>{{ .Date.Format "Jan 02" }}</time>
                <h3>{{ .Title }}</h3>
              </div>
              <!--<div class="new-post">New!</div>-->
            </a>
          </div>
          {{ end }}
        </div>
      </section>
    </section>
  </div>
</section>

{{- $scope := .Site }}
{{- $paginator := .Paginate (where $scope.RegularPages ".Params.type" "!=" "page") }}

{{- if gt $paginator.TotalPages 1}}
<section>
  <div class="container">
    <nav class="pagination">
      {{- if $paginator.HasPrev}}
      <div class="prev-page">
        <a href="{{ $paginator.Prev.URL }}">Próxima Página</a>
      </div>
      {{ end }}
      {{- if $paginator.HasNext}}
      <div class="next-page">
        <a href="{{ $paginator.Next.URL }}">Página Anterior</a>
      </div>
      {{ end }}
    </nav>
  </div>
</section>
{{ end }}

{{ end }}
