An AI-powered search engine with a generative UI
TypeScript generative-aigenerative-uinextjsollamareactsearxngshadcn-uitailwindcsstavilytypescriptupstashvercel-ai-sdk
feat(search): add source favicons to search results display
Yoshiki Miurac0c1817bb076
diff --git a/components/search-section.tsx b/components/search-section.tsxindex 92f87463..6418cc56 100644--- a/components/search-section.tsx+++ b/components/search-section.tsx@@ -16,6 +16,7 @@ import ProcessHeader from './process-header'import { SearchResults } from './search-results'import { SearchResultsImageSection } from './search-results-image'import { Section } from './section'+import { SourceFavicons } from './source-favicons'import {createVideoSearchResults,VideoSearchResults@@ -80,9 +81,14 @@ export function SearchSection({}meta={searchResults && totalResults > 0 ? (- <StatusIndicator icon={Check} iconClassName="text-green-500">- {totalResults} results- </StatusIndicator>+ <div className="flex items-center gap-2">+ <StatusIndicator icon={Check} iconClassName="text-green-500">+ {totalResults} results+ </StatusIndicator>+ {searchResults.results && searchResults.results.length > 0 && (+ <SourceFavicons results={searchResults.results} maxDisplay={3} />+ )}+ </div>) : undefined}/>diff --git a/components/source-favicons.tsx b/components/source-favicons.tsxnew file mode 100644index 00000000..5cca19bb--- /dev/null+++ b/components/source-favicons.tsx@@ -0,0 +1,62 @@+import Image from 'next/image'++import type { SearchResultItem } from '@/lib/types'+import { cn } from '@/lib/utils'++interface SourceFaviconsProps {+ results: SearchResultItem[]+ maxDisplay?: number+ className?: string+}++/**+ * Displays overlapping favicons from search results+ */+export function SourceFavicons({+ results,+ maxDisplay = 3,+ className+}: SourceFaviconsProps) {+ // Extract unique domains from results+ const uniqueDomains = Array.from(+ new Set(+ results.map(result => {+ try {+ return new URL(result.url).hostname+ } catch {+ return null+ }+ })+ )+ )+ .filter((domain): domain is string => domain !== null)+ .slice(0, maxDisplay)++ if (uniqueDomains.length === 0) {+ return null+ }++ return (+ <div className={cn('flex items-center', className)}>+ {uniqueDomains.map((domain, index) => (+ <div+ key={domain}+ className="relative rounded-full border border-background overflow-hidden"+ style={{+ marginLeft: index > 0 ? '-6px' : '0',+ zIndex: uniqueDomains.length - index+ }}+ >+ <Image+ src={`https://www.google.com/s2/favicons?domain=${domain}&sz=16`}+ alt={domain}+ width={16}+ height={16}+ className="bg-background"+ unoptimized+ />+ </div>+ ))}+ </div>+ )+}