Some minor fixes

This commit is contained in:
kbe
2025-08-19 15:23:17 +02:00
parent 3cc9d535ff
commit c84ca1d538
4 changed files with 208 additions and 4 deletions

View File

@@ -0,0 +1,161 @@
{{ define "main" }}
<!-- Page Header -->
<div class="section-sm bg-gray-lighter">
<div class="container text-center">
<h3 class="font-family-playfair">Authors</h3>
<p class="mt-2">Discover all our talented authors and their contributions</p>
</div>
</div>
<!-- Authors Section -->
<div class="section">
<div class="container">
<div class="row g-4">
{{ $authors := slice }}
{{ $authorMap := dict }}
<!-- Collect all unique authors -->
{{ range .Site.RegularPages }}
{{ if .Params.author }}
{{ $authorName := .Params.author }}
{{ $authorSlug := .Params.author_slug | default ($authorName | urlize) }}
<!-- Check if author already exists -->
{{ $existing := false }}
{{ range $authors }}
{{ if eq .name $authorName }}
{{ $existing = true }}
{{ end }}
{{ end }}
<!-- Add new author if not exists -->
{{ if not $existing }}
{{ $author := dict
"name" $authorName
"slug" $authorSlug
"bio" .Params.author_bio
"photo" .Params.author_photo
"website" .Params.author_website
"twitter" .Params.author_twitter
"linkedin" .Params.author_linkedin
"posts" (slice)
}}
{{ $authors = $authors | append $author }}
{{ $authorMap = merge $authorMap (dict $authorName $author) }}
{{ end }}
<!-- Add post to author's posts -->
{{ if $author := index $authorMap $authorName }}
{{ $post := dict
"title" .Title
"permalink" .Permalink
}}
{{ $author := merge $author (dict "posts" ($author.posts | append $post)) }}
{{ $authorMap = merge $authorMap (dict $authorName $author) }}
{{ end }}
{{ end }}
{{ end }}
<!-- Display authors -->
{{ if gt (len $authors) 0 }}
{{ range $authors }}
<div class="col-12 col-md-6 col-lg-4">
<div class="team-box team-box-style-2">
<div class="team-box-img">
{{ if .photo }}
<img src="{{ .photo }}" alt="{{ .name }}">
{{ else }}
<img src="/assets/images/avatar-placeholder.jpg" alt="{{ .name }}">
{{ end }}
<div class="team-box-content">
<h5 class="font-family-poppins">{{ .name }}</h5>
{{ if .bio }}
<p class="font-small">{{ .bio | truncate 120 }}</p>
{{ end }}
<div class="team-box-social">
{{ if .website }}
<a href="{{ .website }}" target="_blank" rel="noopener noreferrer">
<i class="fas fa-globe"></i>
</a>
{{ end }}
{{ if .twitter }}
<a href="https://twitter.com/{{ .twitter }}" target="_blank" rel="noopener noreferrer">
<i class="fab fa-twitter"></i>
</a>
{{ end }}
</div>
{{ if .linkedin }}
<a href="https://linkedin.com/in/{{ .linkedin }}" target="_blank" rel="noopener noreferrer">
<i class="fab fa-linkedin-in"></i>
</a>
{{ end }}
</div>
<div class="mt-3">
<a href="/author/{{ .slug }}" class="button-text-1">
{{ len .posts }} {{ if eq (len .posts) 1 }}Article{{ else }}Articles{{ end }}
</a>
</div>
</div>
</div>
</div>
{{ end }}
{{ else }}
<div class="col-12 text-center py-5">
<h4>No authors found</h4>
<p>No authors have been added yet. Check back soon!</p>
</div>
{{ end }}
</div>
</div>
</div>
<!-- Additional Author Information Section -->
{{ if gt (len $authors) 0 }}
<div class="section bg-gray-lighter">
<div class="container">
<div class="row">
<div class="col-12 text-center">
<h4 class="font-family-playfair mb-4">Our Authors</h4>
<p class="max-width-600 mx-auto">
Meet the talented writers and contributors who bring you insightful content across various topics.
Each author brings their unique perspective and expertise to create valuable content for our readers.
</p>
</div>
</div>
<div class="row mt-5">
<div class="col-12">
<div class="row g-3">
{{ range $authors }}
<div class="col-12 col-md-6">
<div class="d-flex align-items-center p-3 bg-white rounded">
<div class="flex-shrink-0">
{{ if .photo }}
<img src="{{ .photo }}" alt="{{ .name }}" class="rounded-circle" width="60" height="60">
{{ else }}
<div class="bg-gray rounded-circle d-flex align-items-center justify-content-center" style="width: 60px; height: 60px;">
<i class="fas fa-user"></i>
</div>
{{ end }}
</div>
<div class="flex-grow-1 ms-3">
<h6 class="mb-1">{{ .name }}</h6>
<small class="text-muted">{{ len .posts }} {{ if eq (len .posts) 1 }}publication{{ else }}publications{{ end }}</small>
</div>
<div class="flex-shrink-0">
<a href="/author/{{ .slug }}" class="btn btn-sm btn-outline-primary">
<i class="fas fa-arrow-right"></i>
</a>
</div>
</div>
</div>
{{ end }}
</div>
</div>
</div>
</div>
</div>
{{ end }}
{{ end }}

84
layouts/author/list.html Normal file
View File

@@ -0,0 +1,84 @@
{{ 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">
<h3 class="font-family-playfair">Articles by {{ $authorName }}</h3>
<p class="mt-2">Tous les articles écrits par {{ $authorName }}</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="img-link-box">
<a href="{{ .RelPermalink }}">
{{ if .Params.featured_image }}
<img src="{{ .Params.featured_image }}" alt="{{ .Title }}">
{{ else }}
<img src="/assets/images/col-1.jpg" alt="{{ .Title }}">
{{ end }}
</a>
</div>
<div class="mt-4">
<div class="d-flex justify-content-between mb-2">
<div class="d-inline-flex">
{{ if .Params.categories }}
{{ range $index, $category := .Params.categories }}
{{ if $index }}, {{ end }}
{{ if and (eq (printf "%T" $category) "string") }}
<a class="font-family-poppins font-small fw-medium uppercase" href="/categories/{{ $category | urlize }}">{{ $category }}</a>
{{ else if and (eq (printf "%T" $category) "map") }}
{{ if $category.name }}
<a class="font-family-poppins font-small fw-medium uppercase" href="/categories/{{ $category.name | urlize }}">{{ $category.name }}</a>
{{ end }}
{{ end }}
{{ end }}
{{ end }}
</div>
<div class="d-inline-flex">
<span class="font-small">{{ .Date.Format "02/07/2006" }}</span>
</div>
</div>
<h4><a class="text-link-1" href="{{ .RelPermalink }}">{{ .Title }}</a></h4>
{{ 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 }}