import Link from "next/link"; import { Metadata } from "next"; import { cookies } from "next/headers"; import { fetchPosts, fetchBoards } from "@/lib/api"; import Pagination from "@/components/Pagination"; import LikeButton from "@/components/LikeButton"; export const metadata: Metadata = { title: "姜十三论坛 - 技术分享与讨论社区", description: "姜十三论坛,分享技术、讨论问题、交流心得的社区", openGraph: { title: "姜十三论坛 - 技术分享与讨论社区", description: "姜十三论坛,分享技术、讨论问题、交流心得的社区", type: "website", }, }; interface HomePageProps { searchParams: Promise<{ q?: string; page?: string }>; } export default async function HomePage({ searchParams }: HomePageProps) { const { q, page: pageStr } = await searchParams; const keyword = q?.trim() || ""; const page = Math.max(1, parseInt(pageStr || "1", 10) || 1); const cookie = (await cookies()).toString(); const [postsData, boardsData] = await Promise.all([ fetchPosts(page, 20, undefined, "latest", keyword, cookie), fetchBoards(), ]); return (
{keyword ? "没有找到相关帖子" : "暂无帖子,来发第一篇吧!"}
)}