Commit 8aff40f 1 parent 53aad1b commit 8aff40f Copy full SHA for 8aff40f
File tree 1 file changed +5
-5
lines changed
opensaas-sh/blog/src/components
1 file changed +5
-5
lines changed Original file line number Diff line number Diff line change @@ -7,20 +7,20 @@ interface Props {
7
7
8
8
const { src, lgWidth = ' 55%' , smWidth = ' 100%' } = Astro .props ;
9
9
10
- // Function to check if the URL is a YouTube URL and extract the video ID
10
+ // Function to check if the URL is a YouTube URL and, if so, extract the video ID
11
11
function getYouTubeId(url : string ): string | null {
12
12
const regExp = / ^ . * (youtu. be\/ | v\/ | u\/ \w \/ | embed\/ | watch\? v=| &v=)([^ #&?] * ). * / ;
13
13
const match = url .match (regExp );
14
- return match && match [2 ].length === 11 ? match [2 ] : null ;
14
+ return match && match [2 ].length === 11 ? match [2 ] : null ; // Note: all YouTube video IDs are 11 characters long.
15
15
}
16
16
17
- const youtubeId = getYouTubeId (src );
18
- const isYouTube = !! youtubeId ;
17
+ const youTubeId = getYouTubeId (src );
18
+ const isYouTube = !! youTubeId ;
19
19
---
20
20
21
21
{ isYouTube ? (
22
22
<iframe
23
- src = { ` https://www.youtube.com/embed/${youtubeId } ` }
23
+ src = { ` https://www.youtube.com/embed/${youTubeId } ` }
24
24
title = " YouTube video player"
25
25
allow = " accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share"
26
26
allowfullscreen
You can’t perform that action at this time.
0 commit comments