{{ $paginator := .Paginate (where .Data.Pages.ByDate.Reverse "Type" "post") }}
{{ range $paginator.Pages }}

<article class="post-card post"> 
    {{if .Params.image}}
    <a class="post-card-image-link" href="{{ .Permalink }}">
      <div class="post-card-image" style="background-image: url({{.Params.image | absURL}})"></div>
    </a>
    {{else}}
    <a class="post-card-image-link" href="{{ .Permalink }}">
      <div class="post-card-image" style="background-image: url({{$.Site.BaseURL}}defimg/{{ index (seq 7 | shuffle) 0 }}.jpg)"></div>
    </a>    
    {{end}}

    <div class="post-card-content">
      <a class="post-card-content-link" href="{{ .Permalink }}">
          <header class="post-card-header">
              {{if .Params.tags }}<span class="post-card-tags">{{ range $index, $tag := .Params.tags }}
              #{{$tag}} {{end}} </span>
              {{ end }}
              <h2 class="post-card-title">{{.Title}}</h2>
          </header>
          <section class="post-card-excerpt">
              {{ if .Description }} 
                <p>{{ .Description | markdownify }}</p>
              {{else}}
                <p>{{ .Summary | plainify | safeHTML }}{{ if .Truncated }} ... {{end}} </p>
              {{end}}
          </section>
      </a>

      <footer class="post-card-meta">
          <img class="author-profile-image" src="{{ (.Params.authorAvatar | default .Site.Params.authorAvatar) | absURL}}" alt="Author" />
          <span class="post-card-author"><a href="/">{{.Params.author | default .Site.Params.author}}</a></span>
      </footer>
    </div>
</article>
{{ end }}
