Skip to content

Commit 48adc7b

Browse files
committed
v2.0
1 parent 76d5b3c commit 48adc7b

File tree

3 files changed

+1016
-105
lines changed

3 files changed

+1016
-105
lines changed

src/Page/ResoucesHub/Courseslist.jsx

Lines changed: 21 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,6 @@ const courses = [
2929
level: 'Beginner',
3030
domain: ['Web Development', 'Javascript', 'JS', 'Frontend', 'Free'],
3131
courseLink: 'https://youtu.be/sscX432bMZo?si=5ig6-ErKPW97NU5L',
32-
poster: '/assets/Courses/JSHiteshChoudhary.png',
3332
shareLink: '#javascript-part-1-hc',
3433
},
3534
{
@@ -40,7 +39,6 @@ const courses = [
4039
level: 'Beginner',
4140
domain: ['Web Development', 'Javascript', 'JS', 'Frontend', 'Free'],
4241
courseLink: 'https://youtu.be/_TjtAyMkiTI?si=XwtFRiCPTWQNgAOH',
43-
poster: '/assets/Courses/JSHiteshChoudhary.png',
4442
shareLink: '#javascript-part-2-hc',
4543
},
4644
{
@@ -51,7 +49,6 @@ const courses = [
5149
level: 'Beginner',
5250
domain: ['Web Development', 'HTML', 'Frontend', 'Free'],
5351
courseLink: 'https://youtu.be/rklidcZ-aLU?si=2iv5ZV0EypTpTsw7',
54-
poster: '/assets/Courses/HTML1.png',
5552
shareLink: '#htmlbyprashantJain',
5653
},
5754
{
@@ -62,7 +59,6 @@ const courses = [
6259
level: 'Beginner',
6360
domain: ['Web Development', 'CSS', 'Frontend', 'Free'],
6461
courseLink: 'https://youtu.be/OpWjt_wbV4E?si=u_Z9BbUrhim4Ne9_',
65-
poster: '/assets/Courses/CSS1.png',
6662
shareLink: '#cssbyprashantJain',
6763
},
6864
{
@@ -73,7 +69,6 @@ const courses = [
7369
level: 'Beginner',
7470
domain: ['Web Development', 'HTML', 'Frontend', 'Free'],
7571
courseLink: 'https://youtu.be/k7ELO356Npo?si=YYhRTsCFGLGbFF1h',
76-
poster: '/assets/Courses/HTML4.png',
7772
shareLink: '#htmlbylovebabbar',
7873
},
7974
{
@@ -84,7 +79,6 @@ const courses = [
8479
level: 'Beginner',
8580
domain: ['Web Development', 'CSS', 'Frontend', 'Free'],
8681
courseLink: 'https://youtu.be/dSJM4Gyh8jE?si=0DA97_AKrV3bfKFo',
87-
poster: '/assets/Courses/CSS2.png',
8882
shareLink: '#cssbylovebabbar',
8983
},
9084
{
@@ -95,7 +89,6 @@ const courses = [
9589
level: 'Beginner',
9690
domain: ['Web Development', 'HTML', 'CSS', 'Frontend', 'Free'],
9791
courseLink: 'https://youtu.be/G3e-cpL7ofc?si=D5xPjvKi7AnfDFft',
98-
poster: '/assets/Courses/HTML3.png',
9992
shareLink: '#htmlcssbysupersimpledev',
10093
},
10194
{
@@ -106,7 +99,16 @@ const courses = [
10699
level: 'Beginner',
107100
domain: ['Web Development', 'CSS', 'Frontend', 'Free'],
108101
courseLink: 'https://youtu.be/OXGznpKZ_sA?si=_2uGEik_pdGQM_Ks',
109-
poster: '/assets/Courses/CSS3.png',
102+
shareLink: '#htmlbydavegray',
103+
},
104+
{
105+
platform: 'YouTube',
106+
title: 'CSS - English',
107+
instructor: 'Dave Gray',
108+
duration: '11 Hour',
109+
level: 'Beginner',
110+
domain: ['Web Development', 'CSS', 'Frontend', 'Free'],
111+
courseLink: 'https://youtu.be/pN6jk0uUrD8?si=89uQMPPR2rZvjfnY',
110112
shareLink: '#htmlbydavegray',
111113
},
112114
// Add more courses similarly...
@@ -187,6 +189,7 @@ const StyledCoursesCard = styled.div`
187189
}
188190
}
189191
`;
192+
190193
const CoursesCardComponent = ({
191194
platform,
192195
title,
@@ -198,6 +201,15 @@ const CoursesCardComponent = ({
198201
poster,
199202
shareLink,
200203
}) => {
204+
const getYouTubeThumbnail = (url) => {
205+
const videoIdMatch = url.match(
206+
/(?:https?:\/\/)?(?:www\.)?youtu(?:\.be\/|be\.com\/(?:watch\?v=|embed\/|v\/))([\w-]{11})/,
207+
);
208+
return videoIdMatch ? `https://img.youtube.com/vi/${videoIdMatch[1]}/hqdefault.jpg` : poster;
209+
};
210+
211+
const thumbnail = platform === 'YouTube' ? getYouTubeThumbnail(courseLink) : poster;
212+
201213
return (
202214
<StyledCoursesCard id={shareLink.substring(1)}>
203215
<div className="flex items-center justify-between p-2">
@@ -226,7 +238,7 @@ const CoursesCardComponent = ({
226238
</button>
227239
</div>
228240
<img
229-
src={poster}
241+
src={thumbnail}
230242
alt={`${title} Poster`}
231243
className="h-full w-full rounded-lg object-cover"
232244
onError={(e) => {

0 commit comments

Comments
 (0)