Category page ok

This commit is contained in:
kbe
2025-08-20 20:17:37 +02:00
parent 63e117a49a
commit c2ea3a9a4f
3 changed files with 357 additions and 94 deletions

View File

@@ -1,63 +1,81 @@
{{ define "main" }}
<!-- layouts/_default/list.html -->
<div class="section-sm bg-gray-lighter">
<div class="container text-center">
<h1 class="font-family-playfair">{{ .Site.Title }}</h1>
</div><!-- end container -->
</div>
<div class="min-h-screen bg-white">
<!-- Hero Section with Category Title -->
<section class="gradient-bg py-12 md:py-16 lg:py-20">
<div class="container mx-auto px-4 sm:px-6 lg:px-8">
<div class="max-w-4xl mx-auto text-center">
<h1 class="text-4xl md:text-5xl lg:text-6xl font-bold text-gray-900 mb-6">
{{ if .Title }}{{ .Title }}{{ else }}{{ .Site.Title }}{{ end }}
</h1>
{{ if .Description }}
<p class="text-xl text-gray-700 mb-8">{{ .Description }}</p>
{{ else if .Site.Params.seo.description }}
<p class="text-xl text-gray-700 mb-8">{{ .Site.Params.seo.description }}</p>
{{ end }}
<!-- Category tags if this is a taxonomy page -->
{{ if eq .Kind "taxonomy" }}
<div class="flex flex-wrap justify-center gap-3 mb-10">
<span class="tag bg-blue-100 text-blue-800 text-sm font-medium px-3 py-1 rounded-full">{{ .Title }}</span>
</div>
{{ end }}
</div>
</div>
</section>
<!-- 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 := .Paginator $paginationLimit }}
<!-- Latest Articles Section -->
<section id="latest-articles" class="py-12 md:py-16 bg-gray-50">
<div class="container mx-auto px-4 sm:px-6 lg:px-8">
<h2 class="text-3xl font-bold text-gray-900 mb-10 text-center">Articles</h2>
{{ $paginator := .Paginate .Pages 9 }}
<div class="grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-8 mb-12">
{{ 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">
<!-- Display category -->
{{ partial "categories-first.html" . }}
<div class="d-inline-flex">
<span class="font-small">{{ .Date.Format "02/07/2006" }}</span>
</div>
</div>
<h2><a class="text-link-1" href="{{ .RelPermalink }}">{{ .Title }}</a></h2>
{{ if .Params.excerpt }}
<p>{{ .Params.excerpt }}</p>
{{ else if .Summary }}
<p>{{ .Summary }}</p>
<div class="bg-white rounded-xl overflow-hidden shadow-md article-card">
<a href="{{ .RelPermalink }}">
{{ if .Params.featured_image }}
<img src="{{ .Params.featured_image }}" alt="{{ .Title }}" class="w-full h-48 object-cover">
{{ else }}
<p>{{ truncate 200 .Content }}</p>
<img src="/assets/images/col-1.jpg" alt="{{ .Title }}" class="w-full h-48 object-cover">
{{ end }}
<div class="mt-3">
<a class="button-text-1" href="{{ .RelPermalink }}">Lire la suite</a>
</a>
<div class="p-6">
<div class="flex flex-wrap gap-2 mb-3">
{{ if .Params.categories }}
{{ range first 1 .Params.categories }}
<a href="/categories/{{ . | urlize }}" class="bg-blue-100 text-blue-800 text-xs font-medium px-2 py-1 rounded hover:underline">{{ . }}</a>
{{ end }}
{{ end }}
</div>
<h3 class="text-lg font-bold text-gray-900 mb-3"><a href="{{ .RelPermalink }}">{{ .Title }}</a></h3>
<p class="text-gray-600 text-sm mb-4">
{{ if .Params.excerpt }}
{{ .Params.excerpt }}
{{ else if .Summary }}
{{ .Summary }}
{{ else }}
{{ truncate 200 .Content }}
{{ end }}
</p>
<div class="flex items-center justify-between text-sm text-gray-500">
<span>{{ .Date | time.Format "2 Jan 2006" }}</span>
<a href="{{ .RelPermalink }}" class="text-blue-600 hover:text-blue-800 font-medium text-sm">Lire la suite →</a>
</div>
</div>
</div>
<!-- End Blog Post box -->
{{ end }}
<!-- Pagination -->
{{ partial "pagination.html" (dict "Paginator" .Paginator "Page" .) }}
</div>
</div><!-- end row -->
</div><!-- end container -->
<!-- Pagination -->
<div class="flex justify-center mt-12">
{{ if gt .Paginator.TotalPages 1 }}
{{ partial "pagination-tailwind.html" .Paginator }}
{{ end }}
</div>
</div>
</section>
</div>
<!-- end Blog section -->
{{ end }}

View File

@@ -1,44 +0,0 @@
{{ define "main" }}
<!-- layouts/categories/list.html -->
<div class="section-sm bg-gray-lighter">
<div class="container text-center">
<h1 class="font-family-playfair">{{ .Title }}</h1>
</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">
{{ range $.Site.Data.wordpress.categories }}
<!-- Category box -->
<div class="mb-5">
<div class="mt-4">
<div class="d-flex justify-content-between mb-2">
<!-- Display category info -->
<div class="d-inline-flex">
<span class="font-small">Catégorie</span>
</div>
</div>
<h2><a class="text-link-1" href="{{ .link | relURL }}">{{ .name }}</a></h2>
{{ if .description }}
<p>{{ .description | safeHTML }}</p>
{{ else }}
<p>Découvrez tous les articles de la catégorie {{ .name }}.</p>
{{ end }}
<div class="mt-3">
<a class="button-text-1" href="{{ .link | relURL }}">Voir la catégorie</a>
</div>
</div>
</div>
<!-- End Category box -->
{{ if not .IsLast }}<hr class="my-5">{{ end }}
{{ end }}
</div>
</div><!-- end row -->
</div><!-- end container -->
</div>
<!-- end Blog section -->
{{ end }}