Tri des expériences par date de fin décroissante puis date de début (parcours et /code, FR/EN/AR)

This commit is contained in:
Jalil Arfaoui 2026-03-11 23:21:54 +01:00
parent 366d18764b
commit f32cd09940
4 changed files with 24 additions and 4 deletions

View file

@ -56,7 +56,12 @@ function computeDuration(startStr: string, endStr?: string) {
const experiences = (await getLocalizedCollection("experiences", locale)) const experiences = (await getLocalizedCollection("experiences", locale))
.filter((e) => !e.data.draft) .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 presentLabel = t('career', 'present', locale);
const logoAltPrefix = t('career', 'logoAlt', locale); const logoAltPrefix = t('career', 'logoAlt', locale);

View file

@ -20,7 +20,12 @@ const projectsBasePath = getProjectsBasePath(locale);
const experiences = (await getLocalizedCollection("experiences", locale)) const experiences = (await getLocalizedCollection("experiences", locale))
.filter((e) => !e.data.draft) .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); const recentExperiences = experiences.filter((e) => e.data.featured).slice(0, 4);

View file

@ -20,7 +20,12 @@ const projectsBasePath = getProjectsBasePath(locale);
const experiences = (await getLocalizedCollection("experiences", locale)) const experiences = (await getLocalizedCollection("experiences", locale))
.filter((e) => !e.data.draft) .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); const recentExperiences = experiences.filter((e) => e.data.featured).slice(0, 4);

View file

@ -20,7 +20,12 @@ const projectsBasePath = getProjectsBasePath(locale);
const experiences = (await getLocalizedCollection("experiences", locale)) const experiences = (await getLocalizedCollection("experiences", locale))
.filter((e) => !e.data.draft) .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); const recentExperiences = experiences.filter((e) => e.data.featured).slice(0, 4);