From 8aff40ff702056794013e4fe89d8b1027a092c16 Mon Sep 17 00:00:00 2001 From: vincanger <70215737+vincanger@users.noreply.github.com> Date: Tue, 7 Jan 2025 14:49:46 +0100 Subject: [PATCH] Update VideoPlayer.astro --- opensaas-sh/blog/src/components/VideoPlayer.astro | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/opensaas-sh/blog/src/components/VideoPlayer.astro b/opensaas-sh/blog/src/components/VideoPlayer.astro index 5cbd36d8..8b405012 100644 --- a/opensaas-sh/blog/src/components/VideoPlayer.astro +++ b/opensaas-sh/blog/src/components/VideoPlayer.astro @@ -7,20 +7,20 @@ interface Props { const { src, lgWidth = '55%', smWidth = '100%' } = Astro.props; -// Function to check if the URL is a YouTube URL and extract the video ID +// Function to check if the URL is a YouTube URL and, if so, extract the video ID function getYouTubeId(url: string): string | null { const regExp = /^.*(youtu.be\/|v\/|u\/\w\/|embed\/|watch\?v=|&v=)([^#&?]*).*/; const match = url.match(regExp); - return match && match[2].length === 11 ? match[2] : null; + return match && match[2].length === 11 ? match[2] : null; // Note: all YouTube video IDs are 11 characters long. } -const youtubeId = getYouTubeId(src); -const isYouTube = !!youtubeId; +const youTubeId = getYouTubeId(src); +const isYouTube = !!youTubeId; --- {isYouTube ? (