-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #2376 from zeitgeistpm/tr-twitch-embed
Twitch embed on market page
- Loading branch information
Showing
7 changed files
with
203 additions
and
30 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
import { TwitchEmbed, TwitchEmbedProps } from "react-twitch-embed"; | ||
|
||
export const TwitchPlayer = (props: TwitchEmbedProps) => { | ||
return <TwitchEmbed {...props} />; | ||
}; | ||
|
||
export default TwitchPlayer; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
import { isAbsoluteUrl } from "next/dist/shared/lib/utils"; | ||
|
||
export const isLive = async (channelNameOrUrl: string) => { | ||
const res = await fetch( | ||
`https://decapi.me/twitch/uptime/${extractChannelName(channelNameOrUrl)}`, | ||
); | ||
const data = await res.text(); | ||
return res.ok && !data.match(/is offline|error/i); | ||
}; | ||
|
||
export const extractChannelName = (url?: string) => { | ||
if (!url) return null; | ||
if (isAbsoluteUrl(url)) { | ||
return new URL(url ?? "").pathname.replace("/", ""); | ||
} else { | ||
return url; | ||
} | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters