Skip to content

Commit 5567c6b

Browse files
committed
Create speakers.html istead speaker/index.html
1 parent e27a7d3 commit 5567c6b

File tree

3 files changed

+85
-55
lines changed

3 files changed

+85
-55
lines changed

src/data/links.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
},
1818
{
1919
"name": "List of Speakers",
20-
"path": "/speaker"
20+
"path": "/speakers"
2121
},
2222
{
2323
"name": "Speaker Mentorship",

src/pages/speaker/index.astro

Lines changed: 0 additions & 54 deletions
This file was deleted.

src/pages/speakers.astro

Lines changed: 84 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,84 @@
1+
---
2+
import { getCollection } from "astro:content";
3+
import Layout from "../layouts/Layout.astro";
4+
import Prose from "../components/prose/prose.astro";
5+
import { Separator } from "../components/separator/separator";
6+
7+
// Fetch all speaker entries
8+
const speakersCollection = await getCollection("speakers");
9+
10+
// Define the type for the groups object
11+
type Speaker = {
12+
slug: string;
13+
data: {
14+
name: string;
15+
};
16+
};
17+
18+
type Groups = {
19+
[key: string]: Speaker[];
20+
};
21+
22+
// Group speakers by the first letter of their name
23+
const groups: Groups = speakersCollection
24+
.filter((speaker: Speaker) => !!speaker.data.name)
25+
.reduce((acc: Groups, speaker: Speaker) => {
26+
const letter = speaker.data.name[0].toUpperCase();
27+
if (!acc[letter]) {
28+
acc[letter] = [];
29+
}
30+
acc[letter].push(speaker);
31+
return acc;
32+
}, {} as Groups);
33+
34+
const letters = Object.keys(groups).sort((a, b) => a.localeCompare(b));
35+
36+
const title = "Speakers";
37+
38+
const description = "Alphabetical list of all confirmed speakers for the conference";
39+
---
40+
41+
<Layout title={title} description={description}>
42+
<div class="px-6">
43+
<Prose>
44+
<h1>Speakers</h1>
45+
</Prose>
46+
47+
<div class="flex text-3xl font-bold flex-wrap mb-6">
48+
{letters.map((letter) => (
49+
<h3 class="mr-2">
50+
<a href={`#letter-${letter}`}>{letter}</a>
51+
</h3>
52+
))}
53+
</div>
54+
55+
<ol class="speakers">
56+
{letters.map((letter, index) => (
57+
<>
58+
<div id={`letter-${letter}`}>
59+
<h2 class="relative font-title text-primary font-bold mb-[0.6em] [&>a]:border-0 [&>a]:text-inherit text-4xl">
60+
{letter}
61+
</h2>
62+
63+
<ul class="pl-4">
64+
{groups[letter]
65+
.sort((a, b) => a.data.name.localeCompare(b.data.name))
66+
.map((speaker) => (
67+
<li {...{ key: speaker.slug }} class="mb-1">
68+
<a
69+
class="underline hover:text-primary-hover"
70+
href={`/speaker/${speaker.slug}`}
71+
>
72+
{speaker.data.name}
73+
</a>
74+
</li>
75+
))}
76+
</ul>
77+
</div>
78+
79+
{index !== letters.length - 1 ? <Separator /> : <div class="mb-20" />}
80+
</>
81+
))}
82+
</ol>
83+
</div>
84+
</Layout>

0 commit comments

Comments
 (0)