Skip to content

Commit

Permalink
Added video support to news
Browse files Browse the repository at this point in the history
  • Loading branch information
EliteAsian123 committed Jul 12, 2023
1 parent 740c156 commit 7795eb7
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 1 deletion.
13 changes: 13 additions & 0 deletions src/routes/NewsPage/NewsPage.module.css
Original file line number Diff line number Diff line change
Expand Up @@ -93,4 +93,17 @@
display: flex;
align-items: center;
gap: 10px;
}

.video_container {
padding: 24px 0 12px 0;
display: flex;
justify-content: center;
}

.video {
border: none;
border-radius: 8px;
aspect-ratio: calc(16 / 9);
height: 50vh;
}
14 changes: 13 additions & 1 deletion src/routes/NewsPage/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,17 @@ function NewsPage() {
if (isSuccess) {
const { data: articleData, content } = matter(data);

let videoElem = <></>;
if ("video" in articleData) {
videoElem = <div className={styles.video_container}>
<iframe
className={styles.video}
src="https://www.youtube.com/embed/Xk_HqhzvdgQ"
title="YouTube video player"
allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share" />
</div>;
}

return <>
<div className={styles.header} style={{ "--bannerURL": `url(https://raw.githubusercontent.com/YARC-Official/News/master/images/banners/${articleData.banner})` } as CSSProperties}>
<Link to="/" className={styles.header_back}>
Expand Down Expand Up @@ -54,11 +65,12 @@ function NewsPage() {
articleData.release ? (
<div className={styles.releaseDate}>
<TimeIcon />
{ intlFormatDistance(new Date(articleData.release), new Date()) }
{intlFormatDistance(new Date(articleData.release), new Date())}
</div>
) : ""
}
</div>
{videoElem}
<SanitizedHTML dirtyHTML={marked.parse(content)} />
</div>
</>;
Expand Down

0 comments on commit 7795eb7

Please sign in to comment.