Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 4 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -40,13 +40,14 @@
"rehype-slug": "^6.0.0",
"remark-toc": "^9.0.0",
"sharp": "^0.34.0",
"tailwindcss": "^3.4.17",
"typescript": "^5.8.3"
"tailwindcss": "^3.4.17"
},
"devDependencies": {
"@types/js-yaml": "^4.0.9",
"prettier": "^3.5.3",
"prettier-plugin-astro": "^0.14.1"
"prettier-plugin-astro": "^0.14.1",
"tsx": "^4.19.3",
"typescript": "^5.8.3"
},
"prettier": {
"proseWrap": "always"
Expand Down
93 changes: 61 additions & 32 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

55 changes: 34 additions & 21 deletions src/content/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -59,21 +59,23 @@ const keynoters = defineCollection({
}),
});

// Shared data fetching function
async function getCollectionsData() {
const speakersData = await loadData(import.meta.env.EP_SPEAKERS_API);
const sessionsData = await loadData(import.meta.env.EP_SESSIONS_API);

// Create indexed versions for efficient lookups
const speakersById = Object.entries(speakersData).reduce(
const speakersById = Object.entries(
speakersData as Record<string, {}>
).reduce(
(acc, [id, speaker]: [string, any]) => {
acc[id] = { id, ...speaker };
return acc;
},
{} as Record<string, any>
);

const sessionsById = Object.entries(sessionsData).reduce(
const sessionsById = Object.entries(
sessionsData as Record<string, {}>
).reduce(
(acc, [id, session]: [string, any]) => {
acc[id] = { id, ...session };
return acc;
Expand All @@ -93,13 +95,15 @@ const speakers = defineCollection({
loader: async (): Promise<any> => {
const { speakersData, sessionsById } = await getCollectionsData();

return Object.values(speakersData).map((speaker: any) => ({
id: speaker.slug,
...speaker,
submissions: (speaker.submissions || [])
.filter((sessionId: string) => sessionId in sessionsById)
.map((sessionId: string) => sessionsById[sessionId].slug),
}));
return Object.values(speakersData as Record<string, {}>).map(
(speaker: any) => ({
id: speaker.slug,
...speaker,
submissions: (speaker.submissions || [])
.filter((sessionId: string) => sessionId in sessionsById)
.map((sessionId: string) => sessionsById[sessionId].slug),
})
);
},
schema: z.object({
code: z.string(),
Expand All @@ -122,13 +126,15 @@ const sessions = defineCollection({
loader: async (): Promise<any> => {
const { sessionsData, speakersById } = await getCollectionsData();

return Object.values(sessionsData).map((session: any) => ({
id: session.slug,
...session,
speakers: (session.speakers || [])
.filter((speakerId: string) => speakerId in speakersById)
.map((speakerId: string) => speakersById[speakerId].slug),
}));
return Object.values(sessionsData as Record<string, {}>).map(
(session: any) => ({
id: session.slug,
...session,
speakers: (session.speakers || [])
.filter((speakerId: string) => speakerId in speakersById)
.map((speakerId: string) => speakersById[speakerId].slug),
})
);
},
schema: z.object({
code: z.string(),
Expand Down Expand Up @@ -159,13 +165,20 @@ const sessions = defineCollection({
}),
});

interface ScheduleData {
days: Record<string, any>;
}

const days = defineCollection({
loader: async (): Promise<any[]> => {
const schedule = await loadData(import.meta.env.EP_SCHEDULE_API);
const schedule = (await loadData(
import.meta.env.EP_SCHEDULE_API
)) as ScheduleData;

if (Object.keys(schedule).length === 0) {
return schedule;
if (!schedule || Object.keys(schedule).length === 0) {
return [];
}

return Object.entries(schedule.days).map(([date, data]: [string, any]) => ({
id: date,
...data,
Expand Down
Loading