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 for homepage carousel const matchesData = await api.matches.getMatches({ limit: 9 }); return { featuredMatches: matchesData.matches.slice(0, 9), // Get 9 matches for carousel (3 slides) 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.' } }; } };