Files
familienarchiv/frontend/src/routes/documents/+page.ts
Marcel ad82f2e1e2 feat(documents): add fetchDensity helper and /documents/+page.ts (#385)
The density data is fetched only on tablet/desktop (sm:+ breakpoint) and
when ?view=calendar is not set — mobile users and the future calendar view
(#386) skip the request entirely. Lives in +page.ts (client-side) so the
matchMedia gate can run in the browser; +page.server.ts continues to handle
the document search.

Non-ok responses and network failures degrade to an empty bucket list
rather than throwing, so the document list keeps rendering.

5 unit tests cover the gating + graceful degradation paths.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-05-07 22:06:57 +02:00

10 lines
378 B
TypeScript

import { browser } from '$app/environment';
import { fetchDensity } from '$lib/document/timeline';
import type { PageLoad } from './$types';
export const load: PageLoad = async ({ url, fetch }) => {
const view = url.searchParams.get('view');
const isDesktop = browser && window.matchMedia('(min-width: 640px)').matches;
return await fetchDensity(fetch, view, isDesktop);
};