@@ -5,19 +5,34 @@ import { community_videos } from "../data/community-videos.ts";
5
5
6
6
<div class =" community-videos" >
7
7
{
8
- community_videos .map ((item ) => (
9
- <div class = " video-item" >
10
- { /* <span class="comment">{item.comment}</span> */ }
11
- { /* <span class="creator">{item.creator}</span> */ }
12
- <iframe
13
- class = " community-video-youtube-iframe"
14
- src = { ` https://www.youtube-nocookie.com/embed/${item .youtube_id } ` }
15
- title = " YouTube video player"
16
- frameborder = " 0"
17
- allow = " accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share"
18
- referrerpolicy = " strict-origin-when-cross-origin"
19
- allowfullscreen
20
- />
8
+ Object .entries (
9
+ community_videos .reduce (
10
+ (acc : { [key : number ]: typeof community_videos }, item ) => {
11
+ const year = new Date (item .date ).getFullYear ();
12
+ if (! acc [year ]) acc [year ] = [];
13
+ acc [year ].push (item );
14
+ return acc ;
15
+ },
16
+ {},
17
+ ),
18
+ ).map (([year , videos ]) => (
19
+ <div class = " year-group" >
20
+ <h2 >{ year } </h2 >
21
+ { videos .map ((item ) => (
22
+ <div class = " video-item" >
23
+ { /* <span class="comment">{item.comment}</span> */ }
24
+ { /* <span class="creator">{item.creator}</span> */ }
25
+ <iframe
26
+ class = " community-video-youtube-iframe"
27
+ src = { ` https://www.youtube-nocookie.com/embed/${item .youtube_id } ` }
28
+ title = " YouTube video player"
29
+ frameborder = " 0"
30
+ allow = " accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share"
31
+ referrerpolicy = " strict-origin-when-cross-origin"
32
+ allowfullscreen
33
+ />
34
+ </div >
35
+ ))}
21
36
</div >
22
37
))
23
38
}
0 commit comments