{{ define "main" }}
{{ $authorName := .Params.author }}
{{ $authorSlug := .Params.author_slug }}
{{ $authorPosts := where .Site.RegularPages "Params.author" $authorName }}

<div class="section-sm bg-gray-lighter">
  <div class="container text-center">
    <h1 class="font-family-playfair">{{ .Title }}</h1>
    <p class="mt-2">Retrouvez toutes les pages utiles du site ici.</p>
  </div><!-- end container -->
</div>

<!-- Blog section  -->
<div class="section">
  <div class="container">
    <div class="row g-4">
      <div class="col-12 col-sm-10 offset-sm-1 col-md-8 offset-md-2">
        {{ $paginationLimit := 10 }}
        {{ if .Site.Params.paginationLimit }}{{ $paginationLimit = .Site.Params.paginationLimit }}{{ end }}
        {{ $paginator := .Paginate $authorPosts $paginationLimit }}
        
        {{ if gt (len $authorPosts) 0 }}
          {{ range $paginator.Pages }}
          <!-- Blog Post box -->
          <div class="mb-5">
            <div class="mt-4">
              <h2><a class="text-link-1" href="{{ .RelPermalink }}">{{ .Title }}</a></h2>
              {{ if .Params.excerpt }}
                <p>{{ .Params.excerpt }}</p>
              {{ else if .Summary }}
                <p>{{ .Summary }}</p>
              {{ else }}
                <p>{{ truncate 200 .Content }}</p>
              {{ end }}
              <div class="mt-3">
                <a class="button-text-1" href="{{ .RelPermalink }}">Lire la suite</a>
              </div>
            </div>
          </div>
          <!-- End Blog Post box -->
          {{ end }}

          <!-- Pagination -->
          {{ partial "pagination.html" (dict "Paginator" .Paginator "Page" .) }}
        {{ else }}
          <div class="text-center py-5">
            <h4>Aucun article trouvé</h4>
            <p>Aucun article n'a été trouvé pour cet auteur.</p>
          </div>
        {{ end }}
      </div>
    </div><!-- end row -->
  </div><!-- end container -->
</div>
<!-- end Blog section -->
{{ end }}
