Skip to content

Commit 5225d15

Browse files
authored
Fix: Speaker Ordering on Session Pages (#1282) (#1528)
Fixes #1282 Orders speakers predictably on session pages: - Primarily places speakers with no picture and no biography at the bottom - Secondarily sorts alphabetically by first name Follows the guidelines for PRs in EuroPython/website. <!-- readthedocs-preview ep-website start --> 🖼️ Preview available 🖼️ : https://ep-website--1528.org.readthedocs.build/ <!-- readthedocs-preview ep-website end -->
1 parent c4deed9 commit 5225d15

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

src/pages/session/[slug].astro

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,18 @@ const { entry } = Astro.props;
2626
const slug = entry.id;
2727
const speakers = await getEntries(entry.data.speakers);
2828
29+
// Sort speakers according to Issue #1282 rules
30+
speakers.sort((a, b) => {
31+
const aNoPicAndBio = !a.data.avatar && !a.data.biography;
32+
const bNoPicAndBio = !b.data.avatar && !b.data.biography;
33+
34+
if (aNoPicAndBio && !bNoPicAndBio) return 1;
35+
if (!aNoPicAndBio && bNoPicAndBio) return -1;
36+
37+
// Otherwise, sort by first name (alphabetical)
38+
return a.data.name.localeCompare(b.data.name);
39+
});
40+
2941
// Resolve session codes to session data
3042
const resolveSessions = (codes: string[]) =>
3143
codes.map((code) => sessions.find((s) => s.data.code === code)!);

0 commit comments

Comments
 (0)