"use client";

import { doSearch } from "@/app/_lib/actions/search";
import { getLinkList } from "@/app/_lib/data/link";
import { LinkBlock } from "@/app/_ui/LinkListBox";
import { useSearchParams } from "next/navigation"
import useSWR from "swr"
export default function ResultBox() {
    const searchParams = useSearchParams()
    const { data } = useSWR(`${searchParams.get('wd')}`, (e) => doSearch(e))

    return <div className="h-[40vh] w-full px-4">
        <div className="font-bold">搜索结果:{`（共${data?.count || 0}条结果）`}</div>
        <div className="pl-2 border-l-blue-400 border-0 border-l-2 my-2">网站链接</div>
        <div className=" grid grid-cols-3 lg:grid-cols-6 gap-4 ">

            {
                data?.list.map((e: any) => {
                    return <LinkBlock val={e} key={e._id}></LinkBlock>
                })
            }
        </div>
    </div>
}