Skip to content

Commit 2d9540b

Browse files
committed
feat: redesign homepage around search, recent history, and keyword suggestions
Replace the hollow upload-first landing with a tool shell that surfaces recent plays by default, YouTube Music keyword suggestions while typing, and shared result cards—while fixing deep-link watch URLs that were minimized by session restore.
1 parent b525267 commit 2d9540b

9 files changed

Lines changed: 719 additions & 747 deletions

File tree

src/app/api/youtube/search/route.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ function flattenToSearchResults(
2424
export async function GET(request: Request) {
2525
const { searchParams } = new URL(request.url);
2626
const query = searchParams.get("q")?.trim() ?? "";
27-
const limit = Number(searchParams.get("limit") ?? 3);
27+
const limit = Number(searchParams.get("limit") ?? 10);
2828

2929
if (!query) {
3030
return Response.json({ results: [] });
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
import { searchErrorCode } from "@/lib/apiError";
2+
import { getSearchSuggestions } from "@/lib/youtubei";
3+
4+
export async function GET(request: Request) {
5+
const { searchParams } = new URL(request.url);
6+
const query = searchParams.get("q")?.trim() ?? "";
7+
const limit = Number(searchParams.get("limit") ?? 10);
8+
9+
if (!query) {
10+
return Response.json({ suggestions: [] });
11+
}
12+
13+
try {
14+
const suggestions = await getSearchSuggestions(query, {
15+
limit: Math.min(Math.max(limit || 10, 1), 20),
16+
});
17+
return Response.json({ suggestions });
18+
} catch (error) {
19+
const message =
20+
error instanceof Error ? error.message : "Failed to load suggestions.";
21+
console.error("[Moonlit] YouTube suggest error:", message);
22+
const code = searchErrorCode(message);
23+
return Response.json(
24+
{ error: message, suggestions: [], ...(code ? { code } : {}) },
25+
{ status: 500 },
26+
);
27+
}
28+
}

0 commit comments

Comments
 (0)