diff --git a/packages/web/components/Citation.tsx b/packages/web/components/Citation.tsx index 875ce65c..41034319 100644 --- a/packages/web/components/Citation.tsx +++ b/packages/web/components/Citation.tsx @@ -9,9 +9,19 @@ const citationKeyMap: { [key: string]: string } = { source_title: "Source Title", source_name: "Source Name", source_publish_date: "Source Publish Date", - source_url: "Source URL (with timestamp)", + source_url: "Council Meeting", }; +function isYouTubeURL(url: string): boolean { + return url.includes('youtube.com'); +} + +function getYouTubeThumbnail(url: string): string | undefined { + const videoId = url.split("v=")[1]?.split("&")[0]; + if (!videoId) return undefined; + return `https://img.youtube.com/vi/${videoId}/0.jpg`; +} + const Citation = ({ citation, index }: CitationProps) => { const hasMetadata = Object.values(citation).some( (value) => value !== null && value !== "" @@ -26,10 +36,16 @@ const Citation = ({ citation, index }: CitationProps) => { {"\u2022"} {citationKeyMap[key] || key} :{" "} - {key === "source_url" && citation[key] ? ( // Check if the current key is 'source_url' and it exists - - {citation[key]} - + {key === "source_url" && citation[key] ? ( + isYouTubeURL(citation[key]) && getYouTubeThumbnail(citation[key]) ? ( + + + + ) : ( + + {citation[key]} + + ) ) : ( citation[key] )} diff --git a/packages/web/components/NewQuery.tsx b/packages/web/components/NewQuery.tsx index 00c7463e..62d36a0a 100644 --- a/packages/web/components/NewQuery.tsx +++ b/packages/web/components/NewQuery.tsx @@ -24,6 +24,22 @@ function YouTubeEmbed({ url }: { url: string }) { ); } +function YouTubeThumbnail({ url }: { url: string }) { + const videoId = url.split("v=")[1]?.split("&")[0]; + if (!videoId) return null; + + return ( + + + + ); +} + export default function NewQuery() { const apiEndpoint = process.env.NEXT_PUBLIC_TGI_API_ENDPOINT!; const [query, setQuery] = useState(""); @@ -159,7 +175,7 @@ export default function NewQuery() {
{citation.source_title}
{citation.source_url && citation.source_url.includes("youtube.com") && -