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);