import { redirect } from "next/navigation";
import { headers } from "next/headers";
import Feed from "@/components/Feed";
import SearchBar from "@/components/SearchBar";
import { fetchFeedData } from "@/lib/feed.ts";
type Props = {
searchParams?: {
q?: string | undefined;
};
};
export default async function Home({ searchParams }: Props) {
const headerList = headers();
const referer = headerList.get("referer");
if (!referer && searchParams?.q) {
redirect(`/search?q=${searchParams.q}`);
}
const data = await fetchFeedData({});
return (
<>