diff --git a/src/app/page.tsx b/src/app/page.tsx index 5792d71..d141f6f 100644 --- a/src/app/page.tsx +++ b/src/app/page.tsx @@ -1,7 +1,22 @@ +import {redirect} from "next/navigation" +import { headers } from 'next/headers' import Feed from "@/components/Feed" import SearchBar from "@/components/SearchBar" -export default function Home() { +type Props = { + searchParams?: { + q?: string | undefined + }; +} + +export default function Home({searchParams}: Props) { + const headerList = headers() + const referer = headerList.get("referer") + + if(!referer && searchParams?.q) { + redirect(`/search?q=${searchParams.q}`) + } + return ( <> @@ -10,17 +25,17 @@ export default function Home() { { const isActive = results.length > 0 || dirtyInput - useEffect(() => { - if (!dirtyInput && searchParams.get("q") && searchParams.get("q") !== "") { - handleSearch() - } - }, []) - - return (
{ : "w-full p-2" }`} placeholder={ - isActive + !isActive ? "Search for web3 news from the community" : undefined }