Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 21 additions & 10 deletions components/arcade/showcase/youtube-renderer.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,28 @@ import LiteYouTubeEmbed from 'react-lite-youtube-embed';
import 'react-lite-youtube-embed/dist/LiteYouTubeEmbed.css'

const YoutubeRenderer = ({ youtubeLink }) => {
if (!youtubeLink) return null
const youtubeID = youtubeLink.split('v=')[1]
if (!youtubeID) return <p>Invalid YouTube link: "{youtubeLink}"</p>
if (!youtubeLink) return null;

const isYouTubeLink = youtubeLink.includes('youtube.com') || youtubeLink.includes('youtu.be');
if (isYouTubeLink) {
const youtubeID = youtubeLink.split('v=')[1];
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

youtu.be links don't have v query param, thus no youtu.be links would render

if (!youtubeID) return <p>Invalid YouTube link: "{youtubeLink}"</p>;

return (
<LiteYouTubeEmbed
id={youtubeID}
adNetwork={false}
noCookie={true}
/>
);
}
return (
<LiteYouTubeEmbed
id={youtubeID}
adNetwork={false}
noCookie={true}
/>
)
}
<video controls>
<source src={youtubeLink} type="video/mp4" />
Your browser does not support the video tag.
</video>
);
};


export default YoutubeRenderer