import { getRoutines } from '$lib/api'; import type { PageServerLoad } from './$types'; export const load: PageServerLoad = async ({ url }) => { const from_date = url.searchParams.get('from_date') ?? recentDate(30); const routines = await getRoutines({ from_date }); return { routines }; }; function recentDate(daysAgo: number): string { const d = new Date(); d.setDate(d.getDate() - daysAgo); return d.toISOString().slice(0, 10); }