22import VideoButton from ' ./VideoButton.astro' ;
33import ClipboardCopy from ' ./ClipboardCopy.astro' ;
44import { getEntry } from ' astro:content' ;
5+ import AnsweredUser from ' ./github/AnsweredUser.svelte' ;
56
67const { lang } = Astro .props ;
78const { author, challengeNumber, title, blogLink, videoLink, command } = Astro .props .entry .data ;
@@ -11,27 +12,6 @@ const authorLink = `https://github.com/tomalaforge/angular-challenges/pulls?q=la
1112const communityLink = ` https://github.com/tomalaforge/angular-challenges/pulls?q=label%3A${challengeNumber }+label%3Aanswer+sort%3Areactions-%2B1-desc ` ;
1213const npxCommand = ` npx nx serve ${command } ` ;
1314
14- let items = [];
15- let page = 1 ;
16- let error = false ;
17- try {
18- while (true ) {
19- const response = await fetch (` https://api.github.com/search/issues?q=repo:tomalaforge/angular-challenges+is:pr+label:"${challengeNumber }"+label:"answer"&per_page=100&page=${page } ` );
20- if (! response .ok ) {
21- throw new Error (' Network response was not ok' );
22- }
23- const { items : new_items, total_count } = await response .json ();
24- if (! new_items || new_items .length === 0 ) break ;
25- items .push (... new_items );
26-
27- if (total_count < page * 100 ) break ;
28-
29- page ++ ;
30- }
31- } catch (e ) {
32- error = true ;
33- }
34-
3515---
3616
3717<div class =" separator" ></div >
@@ -71,7 +51,7 @@ while (true) {
7151<div class = " article-footer" >
7252 <a
7353 href = { communityLink } >
74- ❖ { items . length > 0 ? items . length : ' ' } { data [' challenge.footer.communityAnswers' ]} *
54+ ❖ { data [' challenge.footer.communityAnswers' ]} *
7555 </a >
7656 <a
7757 href = { authorLink } >
@@ -92,20 +72,7 @@ while (true) {
9272 <VideoButton { ... videoLink } { ... Astro .props } />}
9373</div >
9474
95- { error ? null :
96- <div class = " solution-container" >
97- <div >Answered by</div >
98- { (items ?? []).map ((item ) => (
99- <img
100- loading = " lazy"
101- src = { item .user .avatar_url }
102- width = " 30"
103- height = " 30"
104- alt = " "
105- class = " avatar"
106- />
107- ))}
108- </div >}
75+ <AnsweredUser client :load { challengeNumber } />
10976
11077<div class = " footer-note" >
11178 * { data [' challenge.footer.upvoteAnswer' ]}
@@ -131,16 +98,5 @@ while (true) {
13198 margin - top : 3rem ;
13299 }
133100
134-
135- .solution-container {
136- margin - top : 3rem ;
137- display : flex ;
138- flex - wrap : wrap ;
139- gap : 0.5rem ;
140-
141- img {
142- border-radius: 50 % ;
143- }
144- }
145101</style >
146102
0 commit comments