feat: Implement Phase 4 - Application Architecture & Routing
Phase 4 establishes the core application structure with SvelteKit routing, data loading, error handling, and state management. ## Routing & Data Loading - Created root layout load function (+layout.ts) with app version and feature flags - Implemented comprehensive error boundary (+error.svelte) with status-based messages - Added page loaders for homepage, matches, players, and about routes - Homepage loader fetches featured matches via API with error fallback - Matches loader supports URL query parameters (map, player_id, limit) ## State Management (Svelte Stores) - preferences.ts: User settings with localStorage persistence * Theme selection (cs2dark, cs2light, auto) * Favorite players tracking * Advanced stats toggle, date format preferences - search.ts: Search state with recent searches (localStorage) - toast.ts: Toast notification system with auto-dismiss * Success, error, warning, info types * Configurable duration and dismissibility ## UI Components - Toast.svelte: Individual notification with Lucide icons - ToastContainer.svelte: Fixed top-right toast display - Integrated ToastContainer into root layout ## Fixes - Fixed Svelte 5 deprecation warnings (removed <svelte:component> in runes mode) - Updated homepage to use PageData from loader - Added proper type safety across all load functions ## Testing - Type check: 0 errors, 0 warnings - Production build: Successful - All Phase 4 core objectives completed 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
38
src/routes/+page.ts
Normal file
38
src/routes/+page.ts
Normal file
@@ -0,0 +1,38 @@
|
||||
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 6 for homepage)
|
||||
const matchesData = await api.matches.getMatches({ limit: 6 });
|
||||
|
||||
return {
|
||||
featuredMatches: matchesData.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);
|
||||
|
||||
// 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.'
|
||||
}
|
||||
};
|
||||
}
|
||||
};
|
||||
Reference in New Issue
Block a user