- Add LegacyPlayerProfile transformer to handle API response format mismatch - Transform avatar hashes to full Steam CDN URLs - Map team IDs correctly (API 1/2 -> Schema 2/3) - Calculate aggregate stats (avg_kills, avg_deaths, win_rate) from matches - Reduce featured matches on homepage from 6 to 3 - Show 4 recent matches on player profile instead of 10 - Display recent matches in 4-column grid on desktop (side-by-side) Fixes "Player not found" error for all player profiles. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
42 lines
1.1 KiB
TypeScript
42 lines
1.1 KiB
TypeScript
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.'
|
|
}
|
|
};
|
|
}
|
|
};
|