Skip to content

Commit c9a3168

Browse files
committed
Support MM:SS timestamps for talk slides and update timestamps
1 parent 3e17cf8 commit c9a3168

4 files changed

Lines changed: 78 additions & 7 deletions

File tree

src/components/TalkSlides.astro

Lines changed: 22 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import { resolveSlideImageUrl } from "@/utils/assets";
33
44
interface Slide {
55
image: string;
6-
timestamp?: number;
6+
timestamp?: number | string; // Can be seconds or "MM:SS" format
77
}
88
99
interface Props {
@@ -32,12 +32,32 @@ interface Props {
3232
3333
const { slides, basePath, talkId, syncWithAudio = false, audioPlayerId } = Astro.props;
3434
35+
// Convert "MM:SS" timestamp to seconds
36+
function parseTimestamp(timestamp: number | string | undefined): number | undefined {
37+
if (timestamp === undefined) return undefined;
38+
if (typeof timestamp === "number") return timestamp;
39+
40+
// Parse "MM:SS" or "HH:MM:SS" format
41+
const parts = timestamp.split(":").map(Number);
42+
if (parts.length === 2) {
43+
// MM:SS
44+
return parts[0] * 60 + parts[1];
45+
} else if (parts.length === 3) {
46+
// HH:MM:SS
47+
return parts[0] * 3600 + parts[1] * 60 + parts[2];
48+
}
49+
return undefined;
50+
}
51+
3552
// Normalize slides to array format
3653
const slideList: Slide[] = typeof slides === "number"
3754
? Array.from({ length: slides }, (_, i) => ({
3855
image: `codegen-${i + 1}.png`,
3956
}))
40-
: slides;
57+
: slides.map(slide => ({
58+
...slide,
59+
timestamp: parseTimestamp(slide.timestamp),
60+
}));
4161
4262
// Resolve image URLs with local-first fallback
4363
// Priority: 1) Local file in /assets/, 2) R2 URL from manifest, 3) Fallback path

src/content.config.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ const talks = defineCollection({
5151
z.number(),
5252
z.array(z.object({
5353
image: z.string(),
54-
timestamp: z.number().optional(),
54+
timestamp: z.union([z.number(), z.string()]).optional(),
5555
}))
5656
]).optional(),
5757
audioPath: z.string().optional(),

src/content/manifest.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -152,8 +152,8 @@
152152
"ext": "png"
153153
},
154154
"talks/codegen-in-rust/transcript.json": {
155-
"hash": "15dceaa191253ea1b4ff7ee0874ce4b70607239a27569dfd0181848a785af6b7",
156-
"size": 794028,
155+
"hash": "0f340aaa4c3a847e5e9f2db704a762ca0017e609acf871ce653e5e82c6a7d45f",
156+
"size": 794127,
157157
"ext": "json"
158158
},
159159
"talks/codegen-in-rust/codegen-42.png": {

src/content/talks/t2468--codegen-in-rust.mdx

Lines changed: 53 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,60 +5,111 @@ event: RustNYC
55
location: New York, NY
66
slides:
77
- image: codegen-1.png
8-
timestamp: 0
8+
timestamp: 00:00
99
- image: codegen-2.png
10-
timestamp: 16
10+
timestamp: 00:16
1111
- image: codegen-3.png
12+
timestamp: 01:29
1213
- image: codegen-4.png
14+
timestamp: 02:11
1315
- image: codegen-5.png
16+
timestamp: 02:14
1417
- image: codegen-6.png
18+
timestamp: 02:18
1519
- image: codegen-7.png
20+
timestamp: 02:47
1621
- image: codegen-8.png
22+
timestamp: 03:10
1723
- image: codegen-9.png
24+
timestamp: 03:15
1825
- image: codegen-10.png
26+
timestamp: 03:50
1927
- image: codegen-11.png
28+
timestamp: 03:58
2029
- image: codegen-12.png
30+
timestamp: 04:20
2131
- image: codegen-13.png
32+
timestamp: 04:40
2233
- image: codegen-14.png
34+
timestamp: 05:37
2335
- image: codegen-15.png
36+
timestamp: 06:26
2437
- image: codegen-16.png
38+
timestamp: 06:40
2539
- image: codegen-17.png
40+
timestamp: 07:01
2641
- image: codegen-18.png
42+
timestamp: 07:40
2743
- image: codegen-19.png
44+
timestamp: 08:43
2845
- image: codegen-20.png
46+
timestamp: 09:15
2947
- image: codegen-21.png
48+
timestamp: 09:24
3049
- image: codegen-22.png
50+
timestamp: 10:00
3151
- image: codegen-23.png
52+
timestamp: 10:05
3253
- image: codegen-24.png
54+
timestamp: 10:08
3355
- image: codegen-25.png
56+
timestamp: 10:45
3457
- image: codegen-26.png
58+
timestamp: 11:58
3559
- image: codegen-27.png
60+
timestamp: 13:11
3661
- image: codegen-28.png
62+
timestamp: 14:50
3763
- image: codegen-29.png
64+
timestamp: 15:36
3865
- image: codegen-30.png
66+
timestamp: 16:07
3967
- image: codegen-31.png
68+
timestamp: 16:20
4069
- image: codegen-32.png
70+
timestamp: 16:40
4171
- image: codegen-33.png
72+
timestamp: 16:51
4273
- image: codegen-34.png
74+
timestamp: 17:32
4375
- image: codegen-35.png
76+
timestamp: 18:28
4477
- image: codegen-36.png
78+
timestamp: 18:41
4579
- image: codegen-37.png
80+
timestamp: 18:48
4681
- image: codegen-38.png
82+
timestamp: 19:08
4783
- image: codegen-39.png
84+
timestamp: 19:34
4885
- image: codegen-40.png
86+
timestamp: 19:41
4987
- image: codegen-41.png
88+
timestamp: 20:08
5089
- image: codegen-42.png
90+
timestamp: 20:30
5191
- image: codegen-43.png
92+
timestamp: 21:13
5293
- image: codegen-44.png
94+
timestamp: 21:26
5395
- image: codegen-45.png
96+
timestamp: 22:48
5497
- image: codegen-46.png
98+
timestamp: 23:15
5599
- image: codegen-47.png
100+
timestamp: 23:23
56101
- image: codegen-48.png
102+
timestamp: 24:42
57103
- image: codegen-49.png
104+
timestamp: 25:28
58105
- image: codegen-50.png
106+
timestamp: 28:24
59107
- image: codegen-51.png
108+
timestamp: 28:42
60109
- image: codegen-52.png
110+
timestamp: 28:42
61111
- image: codegen-53.png
112+
timestamp: 30:41
62113
audioPath: /assets/talks/codegen-in-rust/audio.m4a
63114
transcriptPath: /assets/talks/codegen-in-rust/transcript.json
64115
---

0 commit comments

Comments
 (0)