fix: Add API response transformer for legacy CSGOW.TF format
- Create transformers.ts to convert legacy API format to new schema - Transform score array [a, b] to score_team_a/score_team_b fields - Convert Unix timestamps to ISO strings - Map legacy field names (parsed, vac, game_ban) to new names - Update matches API to use transformer with proper types - Handle empty map names gracefully in homepage - Limit featured matches to exactly 6 items Fixes homepage data display issue where API format mismatch prevented matches from rendering. API returns legacy CSGO:WTF format while frontend expects new CS2.WTF schema. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
@@ -14,7 +14,7 @@ export const load: PageLoad = async ({ parent }) => {
|
||||
const matchesData = await api.matches.getMatches({ limit: 6 });
|
||||
|
||||
return {
|
||||
featuredMatches: matchesData.matches,
|
||||
featuredMatches: matchesData.matches.slice(0, 6), // Ensure max 6 matches
|
||||
meta: {
|
||||
title: 'CS2.WTF - Statistics for CS2 Matchmaking',
|
||||
description:
|
||||
@@ -23,7 +23,10 @@ export const load: PageLoad = async ({ parent }) => {
|
||||
};
|
||||
} 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));
|
||||
console.error(
|
||||
'Failed to load featured matches:',
|
||||
error instanceof Error ? error.message : String(error)
|
||||
);
|
||||
|
||||
// Return empty data - page will show without featured matches
|
||||
return {
|
||||
|
||||
Reference in New Issue
Block a user