diff --git a/src/components/ExternalContentHeader.tsx b/src/components/ExternalContentHeader.tsx index 4d186215..33ee95e0 100644 --- a/src/components/ExternalContentHeader.tsx +++ b/src/components/ExternalContentHeader.tsx @@ -4,15 +4,13 @@ import { BookOpen, ExternalLink, Globe, MapPin, User } from 'lucide-react'; import { Avatar, AvatarImage, AvatarFallback } from '@/components/ui/avatar'; import { Skeleton } from '@/components/ui/skeleton'; import { ExternalFavicon } from '@/components/ExternalFavicon'; -import { LinkEmbed, extractYouTubeId, extractTweetId, embedLabel } from '@/components/LinkEmbed'; -import { YouTubeEmbed } from '@/components/YouTubeEmbed'; +import { LinkEmbed, extractYouTubeId, embedLabel } from '@/components/LinkEmbed'; import { useLinkPreview } from '@/hooks/useLinkPreview'; import { useBookInfo } from '@/hooks/useBookInfo'; import { useAuthor } from '@/hooks/useAuthor'; import { useProfileUrl } from '@/hooks/useProfileUrl'; import { genUserName } from '@/lib/genUserName'; import { getCountryInfo } from '@/lib/countries'; -import { cn } from '@/lib/utils'; // --------------------------------------------------------------------------- // Types & helpers @@ -100,126 +98,7 @@ export function seoTitle(content: ExternalContent, appName: string): string { // --------------------------------------------------------------------------- export function UrlContentHeader({ url }: { url: string }) { - const youtubeId = useMemo(() => extractYouTubeId(url), [url]); - const tweetId = useMemo(() => extractTweetId(url), [url]); - const { data, isLoading } = useLinkPreview(url); - - const domain = useMemo(() => { - try { - return new URL(url).hostname.replace(/^www\./, ''); - } catch { - return url; - } - }, [url]); - - // Twitter/X tweet — render the embedded tweet widget - if (tweetId) { - return ; - } - - if (isLoading && !youtubeId) { - return ( -
- -
- - - -
-
- ); - } - - const title = data?.title; - const author = data?.author_name; - const providerName = data?.provider_name || domain; - - if (youtubeId) { - return ( -
- - - -
- - {providerName} - -
- - {title && ( -

- {title} -

- )} - - {author && ( -

- by {author} -

- )} -
-
- ); - } - - const image = data?.thumbnail_url; - - return ( - - {image && ( -
- { - (e.currentTarget.parentElement as HTMLElement).style.display = 'none'; - }} - /> -
- )} - -
-
- - {providerName} - -
- - {title && ( -

- {title} -

- )} - - {!title && ( -

- {url} -

- )} - - {author && ( -

- by {author} -

- )} -
-
- ); + return ; } export function BookContentHeader({ isbn }: { isbn: string }) {