Skip to content

Commit 66715c5

Browse files
committed
fix issues
1 parent 3119053 commit 66715c5

4 files changed

Lines changed: 49 additions & 5 deletions

File tree

‎frontend/main/src/components/PostMedia.tsx‎

Lines changed: 21 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,16 @@ export default function PostMedia({
2222
videoProgress?: number;
2323
setVideoProgress?: (value: SetStateAction<number>) => void;
2424
}): JSX.Element {
25+
const isCloudinary = (): boolean => {
26+
if (post && post?.coverVideo && post?.coverVideo?.url) {
27+
return post.coverVideo?.url.includes('media.codingcat.dev/video') ||
28+
post.coverVideo?.url.includes('res.cloudinary.com/video')
29+
? true
30+
: false;
31+
} else {
32+
return false;
33+
}
34+
};
2535
const isYouTube = (): boolean => {
2636
if (post && post.coverVideo && post.coverVideo.url) {
2737
return post.coverVideo?.url.includes('youtu.be') ||
@@ -43,21 +53,28 @@ export default function PostMedia({
4353
const onProgress = (progress?: { played: number }) => {
4454
progress && setVideoProgress && setVideoProgress(progress.played);
4555
};
46-
56+
const cloudinaryPublicId = isCloudinary()
57+
? post?.coverVideo?.url?.split('/')
58+
: null;
4759
return (
4860
<>
4961
{post?.coverVideo && Object.keys(post.coverVideo).length ? (
5062
<div>
51-
{post.coverVideo?.source === MediaSource.cloudinary ? (
63+
{isCloudinary() ? (
5264
<>
5365
<Video
5466
cloudName={config.name}
55-
publicId={post.coverVideo?.public_id}
67+
publicId={
68+
cloudinaryPublicId
69+
? `${cloudinaryPublicId.at(-2)}/${cloudinaryPublicId
70+
.at(-1)
71+
?.replace('.mp4', '')}`
72+
: undefined
73+
}
5674
privateCdn={config.cname ? true : false}
5775
secure={config.cname ? true : false}
5876
secureDistribution={config.cname ? config.cname : ''}
5977
sourceTypes={['hls', 'webm', 'ogv', 'mp4']}
60-
poster={`https://${config.cname}/image/upload/${post.coverPhoto?.public_id}`}
6178
controls={true}
6279
fluid="true"
6380
style={{ height: '100%', width: '100%' }}

‎frontend/main/src/components/notion-custom-blocks/Embed.tsx‎

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
import { WithContentValidationProps } from '@9gustin/react-notion-render/dist/hoc/withContentValidation';
2+
import { Video } from 'cloudinary-react';
23
import Script from 'next/script';
34
import ReactPlayer from 'react-player/lazy';
5+
import { config as cloudinaryConfig } from '@/config/cloudinary';
46

57
const Embed = ({ config }: { config: WithContentValidationProps }) => {
68
const url =
@@ -58,6 +60,30 @@ const Embed = ({ config }: { config: WithContentValidationProps }) => {
5860
</>
5961
);
6062
}
63+
if (url.includes('https://media.codingcat.dev/video/')) {
64+
const cloudinaryPublicId = url?.split('/');
65+
return (
66+
<Video
67+
cloudName={cloudinaryConfig.name}
68+
publicId={
69+
cloudinaryPublicId
70+
? `${cloudinaryPublicId.at(-2)}/${cloudinaryPublicId
71+
.at(-1)
72+
?.replace('.mp4', '')}`
73+
: undefined
74+
}
75+
privateCdn={cloudinaryConfig.cname ? true : false}
76+
secure={cloudinaryConfig.cname ? true : false}
77+
secureDistribution={
78+
cloudinaryConfig.cname ? cloudinaryConfig.cname : ''
79+
}
80+
sourceTypes={['hls', 'webm', 'ogv', 'mp4']}
81+
controls={true}
82+
fluid="true"
83+
style={{ height: '100%', width: '100%' }}
84+
/>
85+
);
86+
}
6187
return (
6288
<ReactPlayer
6389
className="react-player"

‎frontend/main/src/components/notion-custom-blocks/RenderBlocks.tsx‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ import Embed from '@/components/notion-custom-blocks/Embed';
1010

1111
const myMapper = {
1212
image: withContentValidation(({ className, media }) => {
13+
console.log(media);
1314
return media ? (
1415
<div
1516
style={{

‎frontend/main/src/layout/AppMenu.tsx‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ export default function AppMenu({
4646
href={href}
4747
comparison={comparison}
4848
>
49-
<a className="p-2 links-secondary hover:bg-primary-500" ref={focusme}>
49+
<a className="p-2 links-secondary hover:bg-primary-500">
5050
<span className="sr-only">{`${name}`}</span>
5151
{name}
5252
</a>

0 commit comments

Comments
 (0)