'use client' import { useState } from 'react' import { AvatarImage, Avatar, AvatarFallback } from '@/components/ui-v2/avatar' import { CardContent, Card } from '@/components/ui-v2/card' import { Button } from '@/components/ui-v2/button' import Link from 'next/link' export interface SearchResultsProps { results: { title: string; url: string; content: string }[] } export function SearchResults({ results }: SearchResultsProps) { // State to manage whether to display the results const [showAllResults, setShowAllResults] = useState(false) const handleViewMore = () => { setShowAllResults(true) } const displayedResults = showAllResults ? results : results.slice(0, 3) const additionalResultsCount = results.length > 3 ? results.length - 3 : 0 return (
{displayedResults.map((result: any, index: any) => (

{result.content}

{new URL(result.url).hostname[0]}
{new URL(result.url).hostname}
))} {!showAllResults && additionalResultsCount > 0 && (
)}
) }