import type { PageLoad } from './$types'; import { api } from '$lib/api'; /** * Homepage data loader * Loads featured matches for the homepage */ export const load: PageLoad = async ({ parent }) => { // Wait for parent layout data await parent(); try { // Load featured matches (limit to 3 for homepage) const matchesData = await api.matches.getMatches({ limit: 3 }); return { featuredMatches: matchesData.matches.slice(0, 3), // Ensure max 3 matches meta: { title: 'CS2.WTF - Statistics for CS2 Matchmaking', description: 'Track your CS2 performance, analyze matches, and improve your game with detailed statistics and insights.' } }; } catch (error) { // Log error but don't fail the page load console.error( 'Failed to load featured matches:', error instanceof Error ? error.message : String(error) ); // Return empty data - page will show without featured matches return { featuredMatches: [], meta: { title: 'CS2.WTF - Statistics for CS2 Matchmaking', description: 'Track your CS2 performance, analyze matches, and improve your game with detailed statistics and insights.' } }; } };