import * as React from "react"; import * as Url from "url-parse"; import { VideoWebView } from "./video-webview"; export const isTwitch = (url: string) => { return url.indexOf("twitch.tv/") > -1; }; export const getTwitchEmbed = (url: string) => { let type = "channel"; let id = ""; let query = ""; let parsedUrl = new Url(url); let pathParts = parsedUrl.pathname.split("/"); if (pathParts.length === 2) { id = pathParts[1]; } else { id = pathParts[2]; type = "video"; } query = `${type}=${id}`; return `
`; }; export const TwitchVideo = ({ url }: { url: string }) => { let iframe = React.useMemo(() => getTwitchEmbed(url), [url]); return ; };