From c2ec6c5104d342be989d5acc2f957a964fcd323f Mon Sep 17 00:00:00 2001 From: LATCHIMY Nicolas Date: Sun, 8 Mar 2026 12:53:38 +0400 Subject: [PATCH] =?UTF-8?q?d=C3=A9part=20du=20tavernier?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/pages/index.astro | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/src/pages/index.astro b/src/pages/index.astro index bd2cd5e..7ed3c57 100644 --- a/src/pages/index.astro +++ b/src/pages/index.astro @@ -14,9 +14,17 @@ const eras = allPosts .map((p) => ({ id: p.id, title: p.data.title })); const chroniclesOnly = allPosts.filter((post) => !post.data.isEra); -const sortedPosts = chroniclesOnly.sort( - (a, b) => b.data.publishDate.valueOf() - a.data.publishDate.valueOf(), -); +const sortedPosts = chroniclesOnly.sort((a, b) => { + const dateDiff = + b.data.publishDate.valueOf() - a.data.publishDate.valueOf(); + + // Si les dates sont identiques, on trie par titre (001, 002, etc.) + if (dateDiff === 0) { + return a.data.title.localeCompare(b.data.title); + } + + return dateDiff; +}); const allTags = [ ...new Set(chroniclesOnly.flatMap((post) => post.data.tags || [])), ];