- Public pages (videos, magazine, models): URL-driven search, sort, category/duration
filters, and Prev/Next pagination (page size 24)
- Admin tables (videos, articles): search input, toggle filters, and pagination (page size 50)
- Tags page: tag filtering now done server-side via DB arrayContains query instead of
fetching all items and filtering client-side
- Backend resolvers updated for videos, articles, models with paginated { items, total }
responses and filter/sort/tag args
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
20 lines
746 B
TypeScript
20 lines
746 B
TypeScript
import { adminListArticles } from "$lib/services";
|
|
|
|
export async function load({ fetch, url, cookies }) {
|
|
const token = cookies.get("session_token") || "";
|
|
const search = url.searchParams.get("search") || undefined;
|
|
const category = url.searchParams.get("category") || undefined;
|
|
const featuredParam = url.searchParams.get("featured");
|
|
const featured = featuredParam !== null ? featuredParam === "true" : undefined;
|
|
const offset = parseInt(url.searchParams.get("offset") || "0", 10);
|
|
const limit = 50;
|
|
|
|
const result = await adminListArticles(
|
|
{ search, category, featured, limit, offset },
|
|
fetch,
|
|
token,
|
|
).catch(() => ({ items: [], total: 0 }));
|
|
|
|
return { ...result, search, category, featured, offset, limit };
|
|
}
|