Skip to content

Commit

Permalink
Louisa/media component (#1557)
Browse files Browse the repository at this point in the history
* Fixing media component

* updates

* update package.json

* update media component's width

* update

* revert package
  • Loading branch information
louisachu authored Jan 23, 2024
1 parent 02bf383 commit f376a65
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
9 changes: 9 additions & 0 deletions example/src/pages/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -344,5 +344,14 @@ Inline Alert as a nested component

</InlineNestedAlert>

<Media slots="video"/>

<https://images-tv.adobe.com/mpcv3/5158/d58772af-7a62-49fa-a098-12b11a27fb71_1615917048.854x480at800_h264.mp4#t=3>

<Media slots="video" width="800px" height="600px"/>

<https://video.tv.adobe.com/v/26260/>

<Media slots="video"/>

<https://www.youtube.com/watch?v=mkgpeWbHrjA>
3 changes: 2 additions & 1 deletion packages/gatsby-theme-aio/src/components/Media/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ const Media = ({ video, ...props }) => {
const link = getElementChild(video);
const videos = ["mp4", "3gp", "ogg"];
const url = new URL(link.props.href);
const extension = url.pathname.split(".")[1];
const extension = url.pathname.split(".")?.at(-1);
const youTubeId = getYouTubeId(new URL(link.props.href));
if (youTubeId) {
return (
Expand All @@ -53,6 +53,7 @@ const Media = ({ video, ...props }) => {
src={link.props.href}
css={css`
display: block;
width: 100%;
margin: var(--spectrum-global-dimension-size-400) auto;
`}
{...props}
Expand Down

0 comments on commit f376a65

Please sign in to comment.