diff --git a/src/app/components/AppHeader.tsx b/src/app/components/AppHeader.tsx index e81e371..d2686ee 100644 --- a/src/app/components/AppHeader.tsx +++ b/src/app/components/AppHeader.tsx @@ -1,12 +1,14 @@ import { ThemeToggle } from "@/app/components/ThemeToggle"; +import { SearchBar } from "@/app/components/SearchBar"; export function AppHeader() { return (
msg App
-
diff --git a/src/app/components/PostList.tsx b/src/app/components/PostList.tsx index 673d022..9367f0f 100644 --- a/src/app/components/PostList.tsx +++ b/src/app/components/PostList.tsx @@ -20,13 +20,14 @@ type Resp = { const fetcher = (url: string) => fetch(url).then((r) => r.json()); -export function PostList({ boardId, sort = "recent" }: { boardId?: string; sort?: "recent" | "popular" }) { +export function PostList({ boardId, sort = "recent", q }: { boardId?: string; sort?: "recent" | "popular"; q?: string }) { const pageSize = 10; const getKey = (index: number, prev: Resp | null) => { if (prev && prev.items.length === 0) return null; const page = index + 1; const sp = new URLSearchParams({ page: String(page), pageSize: String(pageSize), sort }); if (boardId) sp.set("boardId", boardId); + if (q) sp.set("q", q); return `/api/posts?${sp.toString()}`; }; const { data, size, setSize, isLoading } = useSWRInfinite(getKey, fetcher); @@ -37,8 +38,18 @@ export function PostList({ boardId, sort = "recent" }: { boardId?: string; sort?
정렬: - 최신 - 인기 + { const p = new URLSearchParams(); if (q) p.set("q", q); if (boardId) p.set("boardId", boardId); p.set("sort", "recent"); return p.toString(); })()}`} + style={{ textDecoration: sort === "recent" ? "underline" : "none" }} + > + 최신 + + { const p = new URLSearchParams(); if (q) p.set("q", q); if (boardId) p.set("boardId", boardId); p.set("sort", "popular"); return p.toString(); })()}`} + style={{ textDecoration: sort === "popular" ? "underline" : "none" }} + > + 인기 +