Skip to content

Commit

Permalink
Youtube tag improvements to now render videos from custom URLs (#343)
Browse files Browse the repository at this point in the history
* Youtube tag can now be used for rendering embedded videos from other custom urls

* change test content

* fix the youtube url use code
  • Loading branch information
aniketkatkar97 authored Dec 4, 2024
1 parent 028422e commit 57e6eb7
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 3 deletions.
1 change: 1 addition & 0 deletions components/common/Youtube/Youtube.interface.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,5 @@ export interface YouTubeProps {
end?: string;
height?: string;
width?: string;
url?: string;
}
10 changes: 7 additions & 3 deletions components/common/Youtube/Youtube.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import classNames from "classnames";
import {YouTubeProps} from "./Youtube.interface";
import { YouTubeProps } from "./Youtube.interface";
import styles from "./Youtube.module.css";

const YouTube = ({
Expand All @@ -9,18 +9,22 @@ const YouTube = ({
end = "",
height,
width,
url = "",
}: YouTubeProps) => {
return (
<div className={classNames(styles.Container, className)}>
<iframe
loading="lazy"
allowFullScreen
src={`https://www.youtube-nocookie.com/embed/${videoId}?rel=0&start=${start}&end=${end}&rel=0`}
src={
url ||
`https://www.youtube-nocookie.com/embed/${videoId}?rel=0&start=${start}&end=${end}&rel=0`
}
className={styles.Iframe}
title="YouTube video player"
frameBorder="0"
allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture"
style={{height, width}}
style={{ height, width }}
></iframe>
</div>
);
Expand Down
3 changes: 3 additions & 0 deletions markdoc/tags/youtube.markdoc.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,5 +20,8 @@ export const youtube = {
width: {
type: Boolean,
},
url: {
type: String,
},
},
};

0 comments on commit 57e6eb7

Please sign in to comment.