Skip to content

Commit

Permalink
updated thumbnail syntax
Browse files Browse the repository at this point in the history
  • Loading branch information
ayyubibrahimi committed Sep 30, 2023
1 parent e41aad6 commit 930c7ac
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions packages/web/components/Citation.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,9 @@ function isYouTubeURL(url: string): boolean {
return url.includes('youtube.com');
}

function getYouTubeThumbnail(url: string): string | null {
function getYouTubeThumbnail(url: string): string | undefined {
const videoId = url.split("v=")[1]?.split("&")[0];
if (!videoId) return null;
if (!videoId) return undefined;
return `https://img.youtube.com/vi/${videoId}/0.jpg`;
}

Expand All @@ -37,9 +37,9 @@ const Citation = ({ citation, index }: CitationProps) => {
</strong>
:{" "}
{key === "source_url" && citation[key] ? (
isYouTubeURL(citation[key]) ? (
isYouTubeURL(citation[key]) && getYouTubeThumbnail(citation[key]) ? (
<a href={citation[key]} target="_blank" rel="noopener noreferrer">
<img src={getYouTubeThumbnail(citation[key])} alt="YouTube Thumbnail" width="200"/>
<img src={getYouTubeThumbnail(citation[key])!} alt="YouTube Thumbnail" width="200"/>
</a>
) : (
<a href={citation[key]} target="_blank" rel="noopener noreferrer">
Expand Down

0 comments on commit 930c7ac

Please sign in to comment.