File tree 1 file changed +19
-0
lines changed
src/components/ui/markdown/renderers
1 file changed +19
-0
lines changed Original file line number Diff line number Diff line change @@ -28,6 +28,21 @@ export const LinkRenderer = ({ href }: { href: string }) => {
28
28
const [ _ , owner , repo ] = url . pathname . split ( '/' )
29
29
return < LinkCard id = { `${ owner } /${ repo } ` } source = "gh" />
30
30
}
31
+
32
+ case isYoutubeUrl ( url ) : {
33
+ const id = url . searchParams . get ( 'v' ) !
34
+ return (
35
+ < div className = "relative h-0 w-full pb-[56%]" >
36
+ < iframe
37
+ src = { `https://www.youtube.com/embed/${ id } ` }
38
+ className = "absolute inset-0 h-full w-full border-0"
39
+ allow = "accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture"
40
+ allowFullScreen
41
+ title = "YouTube video player"
42
+ />
43
+ </ div >
44
+ )
45
+ }
31
46
}
32
47
}
33
48
// fallback to default renderer
@@ -53,3 +68,7 @@ const isGithubRepoUrl = (url: URL) => {
53
68
url . pathname . split ( '/' ) . length === 3
54
69
)
55
70
}
71
+
72
+ const isYoutubeUrl = ( url : URL ) => {
73
+ return url . hostname === 'www.youtube.com' && url . pathname . startsWith ( '/watch' )
74
+ }
You can’t perform that action at this time.
0 commit comments