diff --git a/surfsense_web/components/tool-ui/article/index.tsx b/surfsense_web/components/tool-ui/article/index.tsx index 5669ea832..0a9a2dbde 100644 --- a/surfsense_web/components/tool-ui/article/index.tsx +++ b/surfsense_web/components/tool-ui/article/index.tsx @@ -8,7 +8,8 @@ import { FileTextIcon, UserIcon, } from "lucide-react"; -import { Component, type ReactNode, useCallback } from "react"; +import { Component, type ReactNode, useCallback, useState } from "react"; +import Image from "next/image"; import { z } from "zod"; import { Card, CardContent } from "@/components/ui/card"; import { Tooltip, TooltipContent, TooltipProvider, TooltipTrigger } from "@/components/ui/tooltip"; @@ -126,6 +127,30 @@ function formatWordCount(count: number): string { return `${count} words`; } +/** + * Favicon component that fetches the site icon via Google's favicon service, + * falling back to BookOpenIcon on error. + */ +function SiteFavicon({ domain }: { domain: string }) { + const [failed, setFailed] = useState(false); + + if (failed) { + return ; + } + + return ( + {`${domain} setFailed(true)} + unoptimized + /> + ); +} + /** * Article card component for displaying scraped webpage content */ @@ -198,27 +223,33 @@ export function Article({ }} > {/* Header */} - -
- {/* Icon */} -
- -
+ +
+ {/* Favicon / Icon */} + {domain ? ( +
+ +
+ ) : ( +
+ +
+ )} {/* Content */}
{/* Title */} -

+

{title}

{/* Description */} {description && ( -

{description}

+

{description}

)} {/* Metadata row */} -
+
{domain && ( @@ -275,12 +306,6 @@ export function Article({
- {/* External link indicator */} - {href && ( -
- -
- )}
{/* Response actions */} diff --git a/surfsense_web/components/tool-ui/scrape-webpage.tsx b/surfsense_web/components/tool-ui/scrape-webpage.tsx index a486d6fe0..17cfb218b 100644 --- a/surfsense_web/components/tool-ui/scrape-webpage.tsx +++ b/surfsense_web/components/tool-ui/scrape-webpage.tsx @@ -87,18 +87,12 @@ function ScrapeCancelledState({ url }: { url: string }) { * Parsed Article component with error handling */ function ParsedArticle({ result }: { result: unknown }) { - const article = parseSerializableArticle(result); + const { description, ...article } = parseSerializableArticle(result); return (
{ - if (id === "open" && article.href) { - window.open(article.href, "_blank", "noopener,noreferrer"); - } - }} /> ); }