Skip to content

Commit 6c86739

Browse files
committed
Fix speaker ordering on session pages (#1282)
- Ordered speakers primarily by whether they have both a biography and an avatar (those without are placed at the bottom). - Sorted by first name alphabetically.
1 parent f5a6327 commit 6c86739

1 file changed

Lines changed: 12 additions & 0 deletions

File tree

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)