diff --git a/apps/web/components/dashboard/bookmarks/LinkCard.tsx b/apps/web/components/dashboard/bookmarks/LinkCard.tsx index 230baf02c..f0b8768ec 100644 --- a/apps/web/components/dashboard/bookmarks/LinkCard.tsx +++ b/apps/web/components/dashboard/bookmarks/LinkCard.tsx @@ -1,8 +1,11 @@ "use client"; +import { useState } from "react"; import Image from "next/image"; import Link from "next/link"; import { useUserSettings } from "@/lib/userSettings"; +import { cn } from "@/lib/utils"; +import { Play } from "lucide-react"; import type { ZBookmarkTypeLink } from "@karakeep/shared/types/bookmarks"; import { @@ -39,6 +42,119 @@ function LinkTitle({ bookmark }: { bookmark: ZBookmarkTypeLink }) { ); } +function getYouTubeId(url: string): string | null { + const m = url.match( + /(?:youtube\.com\/(?:watch\?(?:.*&)?v=|embed\/|shorts\/|v\/)|youtu\.be\/)([\w-]{11})/, + ); + return m ? m[1] : null; +} + +function getVimeoId(url: string): string | null { + const m = url.match(/vimeo\.com\/(?:video\/)?(\d+)/); + return m ? m[1] : null; +} + +function isVideoUrl(url: string): boolean { + return !!(getYouTubeId(url) || getVimeoId(url)); +} + +/** + * Plays videos inline on the bookmark card: + * - self-hosted videos archived by yt-dlp (videoAssetId) via a native