feat: add server-side pagination, search, and filtering to all collection and admin pages

- 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>
This commit is contained in:
2026-03-07 10:43:26 +01:00
parent c90c09da9a
commit 9c5dba5c90
17 changed files with 1159 additions and 496 deletions

View File

@@ -1,7 +1,20 @@
import { adminListVideos } from "$lib/services";
export async function load({ fetch, cookies }) {
export async function load({ fetch, url, cookies }) {
const token = cookies.get("session_token") || "";
const videos = await adminListVideos(fetch, token).catch(() => []);
return { videos };
const search = url.searchParams.get("search") || undefined;
const featuredParam = url.searchParams.get("featured");
const premiumParam = url.searchParams.get("premium");
const featured = featuredParam !== null ? featuredParam === "true" : undefined;
const premium = premiumParam !== null ? premiumParam === "true" : undefined;
const offset = parseInt(url.searchParams.get("offset") || "0", 10);
const limit = 50;
const result = await adminListVideos(
{ search, featured, premium, limit, offset },
fetch,
token,
).catch(() => ({ items: [], total: 0 }));
return { ...result, search, featured, premium, offset, limit };
}