-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
✨Video Embed - Added Vimeo Support (#1075)
* Added Vimeo support * Undid newsletters table modification * Changed description of video URL * Fixed broken industry renderer video embed * Fixed livestream widget references * Remove comments * TinaCMS content update by Brady Stroud * Remove testing change --------- Co-authored-by: Brady Stroud [SSW] <[email protected]> Co-authored-by: tina-cloud-app[bot] <58178390+tina-cloud-app[bot]@users.noreply.github.com>
- Loading branch information
1 parent
b0b3200
commit d9886ce
Showing
9 changed files
with
126 additions
and
38 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
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,27 @@ | ||
import classNames from "classnames"; | ||
import Script from "next/script"; | ||
|
||
export type VimeoEmbedProps = { | ||
className?: string; | ||
id: string; | ||
autoplay?: boolean; | ||
}; | ||
|
||
export const VimeoEmbed = ({ className, id, autoplay }: VimeoEmbedProps) => { | ||
return ( | ||
<> | ||
<iframe | ||
className={classNames(className, "h-full w-full")} | ||
src={`https://player.vimeo.com/video/${id}?h=62ccd0699b&autoplay=${ | ||
autoplay ? 1 : 0 | ||
}&title=0&byline=0&portrait=0`} | ||
allow="autoplay; fullscreen; picture-in-picture" | ||
allowFullScreen | ||
/> | ||
<Script | ||
src="https://player.vimeo.com/api/player.js" | ||
strategy="lazyOnload" | ||
/> | ||
</> | ||
); | ||
}; |
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
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 |
---|---|---|
@@ -1,9 +1,19 @@ | ||
// Taken from https://github.com/cookpete/react-player/blob/master/src/patterns.js#L3 | ||
const MATCH_URL_YOUTUBE = | ||
export const MATCH_URL_YOUTUBE = | ||
/(?:youtu\.be\/|youtube(?:-nocookie|education)?\.com\/(?:embed\/|v\/|watch\/|watch\?v=|watch\?.+&v=|shorts\/|live\/))((\w|-){11})|youtube\.com\/playlist\?list=|youtube\.com\/user\//; | ||
// Taken from https://stackoverflow.com/questions/41208456/javascript-regex-vimeo-id | ||
/* eslint-disable no-useless-escape */ | ||
export const MATCH_URL_VIMEO = | ||
/(?:www\.|player\.)?vimeo.com\/(?:channels\/(?:\w+\/)?|groups\/(?:[^\/]*)\/videos\/|album\/(?:\d+)\/video\/|video\/|)(\d+)(?:[a-zA-Z0-9_\-]+)?/i; | ||
|
||
export const getYouTubeId = (url: string) => { | ||
if (!url) return ""; | ||
const match = url.match(MATCH_URL_YOUTUBE); | ||
return match && match[1]; | ||
}; | ||
|
||
export const getVimeoId = (url: string) => { | ||
if (!url) return ""; | ||
const match = url.match(MATCH_URL_VIMEO); | ||
return match && match[1]; | ||
}; |
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