From f32cd09940a37aa4fad8eb033fb787019a2d57c6 Mon Sep 17 00:00:00 2001 From: Jalil Arfaoui Date: Wed, 11 Mar 2026 23:21:54 +0100 Subject: [PATCH] =?UTF-8?q?Tri=20des=20exp=C3=A9riences=20par=20date=20de?= =?UTF-8?q?=20fin=20d=C3=A9croissante=20puis=20date=20de=20d=C3=A9but=20(p?= =?UTF-8?q?arcours=20et=20/code,=20FR/EN/AR)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/components/code/CareerTimeline.astro | 7 ++++++- src/pages/ar/برمجة/index.astro | 7 ++++++- src/pages/code/index.astro | 7 ++++++- src/pages/en/code/index.astro | 7 ++++++- 4 files changed, 24 insertions(+), 4 deletions(-) diff --git a/src/components/code/CareerTimeline.astro b/src/components/code/CareerTimeline.astro index f54a078..77bdd39 100644 --- a/src/components/code/CareerTimeline.astro +++ b/src/components/code/CareerTimeline.astro @@ -56,7 +56,12 @@ function computeDuration(startStr: string, endStr?: string) { const experiences = (await getLocalizedCollection("experiences", locale)) .filter((e) => !e.data.draft) - .sort((a, b) => (b.data.startDate! > a.data.startDate! ? 1 : -1)); + .sort((a, b) => { + const endA = a.data.endDate ?? '9999-12'; + const endB = b.data.endDate ?? '9999-12'; + if (endA !== endB) return endB > endA ? 1 : -1; + return b.data.startDate! > a.data.startDate! ? 1 : -1; + }); const presentLabel = t('career', 'present', locale); const logoAltPrefix = t('career', 'logoAlt', locale); diff --git a/src/pages/ar/برمجة/index.astro b/src/pages/ar/برمجة/index.astro index f5ded2b..8c0d27f 100644 --- a/src/pages/ar/برمجة/index.astro +++ b/src/pages/ar/برمجة/index.astro @@ -20,7 +20,12 @@ const projectsBasePath = getProjectsBasePath(locale); const experiences = (await getLocalizedCollection("experiences", locale)) .filter((e) => !e.data.draft) - .sort((a, b) => (b.data.startDate > a.data.startDate ? 1 : -1)); + .sort((a, b) => { + const endA = a.data.endDate ?? '9999-12'; + const endB = b.data.endDate ?? '9999-12'; + if (endA !== endB) return endB > endA ? 1 : -1; + return b.data.startDate > a.data.startDate ? 1 : -1; + }); const recentExperiences = experiences.filter((e) => e.data.featured).slice(0, 4); diff --git a/src/pages/code/index.astro b/src/pages/code/index.astro index 8189d25..56aa752 100644 --- a/src/pages/code/index.astro +++ b/src/pages/code/index.astro @@ -20,7 +20,12 @@ const projectsBasePath = getProjectsBasePath(locale); const experiences = (await getLocalizedCollection("experiences", locale)) .filter((e) => !e.data.draft) - .sort((a, b) => (b.data.startDate > a.data.startDate ? 1 : -1)); + .sort((a, b) => { + const endA = a.data.endDate ?? '9999-12'; + const endB = b.data.endDate ?? '9999-12'; + if (endA !== endB) return endB > endA ? 1 : -1; + return b.data.startDate > a.data.startDate ? 1 : -1; + }); const recentExperiences = experiences.filter((e) => e.data.featured).slice(0, 4); diff --git a/src/pages/en/code/index.astro b/src/pages/en/code/index.astro index 9da6fa7..4142827 100644 --- a/src/pages/en/code/index.astro +++ b/src/pages/en/code/index.astro @@ -20,7 +20,12 @@ const projectsBasePath = getProjectsBasePath(locale); const experiences = (await getLocalizedCollection("experiences", locale)) .filter((e) => !e.data.draft) - .sort((a, b) => (b.data.startDate > a.data.startDate ? 1 : -1)); + .sort((a, b) => { + const endA = a.data.endDate ?? '9999-12'; + const endB = b.data.endDate ?? '9999-12'; + if (endA !== endB) return endB > endA ? 1 : -1; + return b.data.startDate > a.data.startDate ? 1 : -1; + }); const recentExperiences = experiences.filter((e) => e.data.featured).slice(0, 4);