22import { z } from " astro:schema" ;
33import { Badge } from " @astrojs/starlight/components" ;
44import parse from " parse-duration" ;
5+ import Details from " ./Details.astro" ;
56
67type Props = z .input <typeof props >;
78
@@ -12,12 +13,12 @@ const props = z
1213 thumbnail: z .string ().optional (),
1314 chapters: z .record (z .string (), z .string ()).optional (),
1415 showMoreVideos: z .boolean ().default (false ),
16+ expandChapters: z .boolean ().default (false ),
1517 })
1618 .strict ();
1719
18- const { id, title, thumbnail, chapters, showMoreVideos } = props .parse (
19- Astro .props ,
20- );
20+ const { id, title, thumbnail, chapters, showMoreVideos, expandChapters } =
21+ props .parse (Astro .props );
2122
2223const BASE_URL = ` https://customer-1mwganm1ma0xgnmj.cloudflarestream.com/ ` ;
2324
@@ -53,42 +54,43 @@ if (thumbnail) {
5354
5455 {
5556 chapters && (
56- <p >
57- <strong >Chapters</strong >
58- <ul class = " flex list-none gap-4 overflow-x-scroll pb-4 pl-0" >
59- { Object .entries (chapters ).map (([chapter , time ]) => {
60- const totalSeconds = parse (time , " s" );
61-
62- const thumbnail = new URL (thumbnailUrl );
63- thumbnail .searchParams .set (" fit" , " crop" );
64- thumbnail .searchParams .set (" time" , ` ${totalSeconds }s ` );
65-
66- return (
67- <li class = " mt-0!" >
68- <button
69- class = " flex h-full w-36 cursor-pointer flex-col rounded-sm border border-gray-200 bg-transparent p-4 dark:border-gray-700"
70- data-chapter = { chapter }
71- data-time = { totalSeconds }
72- >
73- <img
74- src = { thumbnail .toString ()}
75- alt = { chapter }
76- width = " 120"
77- height = " 64"
78- class = " border-accent bg-accent/10 rounded-sm border"
79- />
80- <div class = " flex h-full flex-col items-center justify-between" >
81- <strong class = " line-clamp-2 text-xs" title = { chapter } >
82- { chapter }
83- </strong >
84- <Badge text = { time } variant = " tip" class = " w-fit" />
85- </div >
86- </button >
87- </li >
88- );
89- })}
90- </ul >
91- </p >
57+ <Details header = " Chapters" open = { expandChapters } >
58+ <p >
59+ <ul class = " flex list-none gap-4 overflow-x-scroll pb-4 pl-0" >
60+ { Object .entries (chapters ).map (([chapter , time ]) => {
61+ const totalSeconds = parse (time , " s" );
62+
63+ const thumbnail = new URL (thumbnailUrl );
64+ thumbnail .searchParams .set (" fit" , " crop" );
65+ thumbnail .searchParams .set (" time" , ` ${totalSeconds }s ` );
66+
67+ return (
68+ <li class = " mt-0!" >
69+ <button
70+ class = " flex h-full w-36 cursor-pointer flex-col rounded-sm border border-gray-200 bg-transparent p-4 dark:border-gray-700"
71+ data-chapter = { chapter }
72+ data-time = { totalSeconds }
73+ >
74+ <img
75+ src = { thumbnail .toString ()}
76+ alt = { chapter }
77+ width = " 120"
78+ height = " 64"
79+ class = " border-accent bg-accent/10 rounded-sm border"
80+ />
81+ <div class = " flex h-full flex-col items-center justify-between" >
82+ <strong class = " line-clamp-2 text-xs" title = { chapter } >
83+ { chapter }
84+ </strong >
85+ <Badge text = { time } variant = " tip" class = " w-fit" />
86+ </div >
87+ </button >
88+ </li >
89+ );
90+ })}
91+ </ul >
92+ </p >
93+ </Details >
9294 )
9395 }
9496
0 commit comments