diff --git a/src/components/Embed.jsx b/src/components/Embed.jsx new file mode 100644 index 00000000..5629c2e7 --- /dev/null +++ b/src/components/Embed.jsx @@ -0,0 +1,259 @@ +const Embed = ({url}) => { + const parsedUrl = new URL(url); + + if (youtubeHosts.has(parsedUrl.host)) { + return ; + } + if (twitterHosts.has(parsedUrl.host)) { + return ; + } + if (redditHosts.has(parsedUrl.host)) { + return ; + } + if (twitchHosts.has(parsedUrl.host)) { + return ; + } + if (tiktokHosts.has(parsedUrl.host)) { + return ; + } + if (instagramHosts.has(parsedUrl.host)) { + return ; + } + if (odyseeHosts.has(parsedUrl.host)) { + return ; + } + if (bitchuteHosts.has(parsedUrl.host)) { + return ; + } + if (streamableHosts.has(parsedUrl.host)) { + return ; + } + if (spotifyHosts.has(parsedUrl.host)) { + return ; + } +}; + +const youtubeHosts = new Set(['youtube.com', 'www.youtube.com', 'youtu.be', 'www.youtu.be']); + +const YoutubeEmbed = ({parsedUrl}) => { + let youtubeId; + if (parsedUrl.host.endsWith('youtu.be')) { + youtubeId = parsedUrl.pathname.replaceAll('/', ''); + } + else { + youtubeId = parsedUrl.searchParams.get('v'); + } + return