Skip to content

Commit acde29b

Browse files
committed
Remove temporary scripts generate content from fetched files.
1 parent 38b0d50 commit acde29b

File tree

7 files changed

+69
-196
lines changed

7 files changed

+69
-196
lines changed

Makefile

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,8 +31,6 @@ pre:
3131

3232
install:
3333
pnpm install
34-
pnpm update_data
35-
pnpm generate_content
3634

3735
dev:
3836
pnpm dev

astro.config.mjs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,6 @@ export default defineConfig({
6060
"/sponsor/": "/sponsorship/sponsor/",
6161
"/voting/": "/programme/voting/",
6262
"/wasm-summit/": "/programme/wasm-summit/",
63-
"/sessions/": "/programme/sessions/",
6463
},
6564
integrations: [
6665
mdx(),

package.json

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,7 @@
55
"scripts": {
66
"dev": "astro dev",
77
"start": "astro dev",
8-
"build": "pnpm generate_content && astro check && astro build && pnpm pagefind --site dist",
9-
"update_data": "NODE_TLS_REJECT_UNAUTHORIZED=0 node src/scripts/fetchData.js",
10-
"generate_content": "node src/scripts/generateContent.js",
8+
"build": "astro check && astro build && pnpm pagefind --site dist",
119
"preview": "astro preview",
1210
"astro": "astro",
1311
"format": "prettier --write --plugin=prettier-plugin-astro ."

src/content/config.ts

Lines changed: 68 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -55,8 +55,64 @@ const keynoters = defineCollection({
5555
}),
5656
});
5757

58+
// Cache for fetched data to prevent duplicate network requests
59+
let cachedSpeakersData: any = null;
60+
let cachedSessionsData: any = null;
61+
62+
// Shared data fetching function
63+
async function getCollectionsData() {
64+
// Only fetch if not already cached
65+
if (!cachedSpeakersData || !cachedSessionsData) {
66+
const [speakersResponse, sessionsResponse] = await Promise.all([
67+
fetch(
68+
"https://gist.github.com/egeakman/469f9abb23a787df16d8787f438dfdb6/raw/62d2b7e77c1b078a0e27578c72598a505f9fafbf/speakers.json"
69+
),
70+
fetch(
71+
"https://gist.githubusercontent.com/egeakman/eddfb15f32ae805e8cfb4c5856ae304b/raw/466f8c20c17a9f6c5875f973acaec60e4e4d0fae/sessions.json"
72+
),
73+
]);
74+
75+
cachedSpeakersData = await speakersResponse.json();
76+
cachedSessionsData = await sessionsResponse.json();
77+
}
78+
79+
// Create indexed versions for efficient lookups
80+
const speakersById = Object.entries(cachedSpeakersData).reduce(
81+
(acc, [id, speaker]: [string, any]) => {
82+
acc[id] = { id, ...speaker };
83+
return acc;
84+
},
85+
{} as Record<string, any>
86+
);
87+
88+
const sessionsById = Object.entries(cachedSessionsData).reduce(
89+
(acc, [id, session]: [string, any]) => {
90+
acc[id] = { id, ...session };
91+
return acc;
92+
},
93+
{} as Record<string, any>
94+
);
95+
96+
return {
97+
speakersData: cachedSpeakersData,
98+
sessionsData: cachedSessionsData,
99+
speakersById,
100+
sessionsById,
101+
};
102+
}
103+
58104
const speakers = defineCollection({
59-
loader: file("src/content/speakers/data.json"),
105+
loader: async (): Promise<any> => {
106+
const { speakersData, sessionsById } = await getCollectionsData();
107+
108+
return Object.values(speakersData).map((speaker: any) => ({
109+
id: speaker.slug,
110+
...speaker,
111+
submissions: (speaker.submissions || [])
112+
.filter((sessionId: string) => sessionId in sessionsById)
113+
.map((sessionId: string) => sessionsById[sessionId].slug),
114+
}));
115+
},
60116
schema: z.object({
61117
code: z.string(),
62118
name: z.string(),
@@ -74,7 +130,17 @@ const speakers = defineCollection({
74130
});
75131

76132
const sessions = defineCollection({
77-
loader: file("src/content/sessions/data.json"),
133+
loader: async (): Promise<any> => {
134+
const { sessionsData, speakersById } = await getCollectionsData();
135+
136+
return Object.values(sessionsData).map((session: any) => ({
137+
id: session.slug,
138+
...session,
139+
speakers: (session.speakers || [])
140+
.filter((speakerId: string) => speakerId in speakersById)
141+
.map((speakerId: string) => speakersById[speakerId].slug),
142+
}));
143+
},
78144
schema: z.object({
79145
code: z.string(),
80146
title: z.string(),

src/pages/speaker/[slug].astro

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@ export async function getStaticPaths() {
1515
}
1616
1717
const {entry} = Astro.props;
18-
1918
const sessions = await getEntries(entry.data.submissions);
2019
2120
// Get @username from Twitter URL

src/scripts/fetchData.js

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

src/scripts/generateContent.js

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

0 commit comments

Comments
 (0)