-
-
Notifications
You must be signed in to change notification settings - Fork 12
Expand file tree
/
Copy pathcover-media.tsx
More file actions
36 lines (32 loc) · 1.01 KB
/
cover-media.tsx
File metadata and controls
36 lines (32 loc) · 1.01 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
import dynamic from "next/dynamic";
const YouTube = dynamic(() =>
import("@/components/youtube").then((mod) => mod.YouTube),
);
const CoverImage = dynamic(() => import("@/components/cover-image"));
const CoverVideo = dynamic(() => import("@/components/cover-video"));
export interface CoverMediaProps {
cloudinaryImage: any;
cloudinaryVideo: any;
youtube: string | null | undefined;
className?: string;
}
export default function CoverMedia(props: CoverMediaProps) {
const { cloudinaryImage, cloudinaryVideo, youtube, className } = props;
if (cloudinaryVideo?.asset?._ref) {
return (
<CoverVideo cloudinaryVideo={cloudinaryVideo} className={className} />
);
}
if (youtube) {
return (
<YouTube
youtube={youtube}
image={cloudinaryImage}
className={className}
/>
);
}
return (
<CoverImage image={cloudinaryImage} priority={true} className={className} />
);
}