import {compareDate} from "../_utils/date.ts" import { GameData } from "../_utils/game.ts"; import {GameTable} from "../_components/GameTable.tsx" import {compare_progress} from "../_utils/progress.ts" import {GlobalData} from "../_utils/site.ts" export const layout = "base.tsx" export default function(data: GlobalData, helpers: Lume.Helpers) { const intro_section = data.content ? ( {data.children} ) : null const games: GameData[] = data.search.pages("game") const active_games = games .filter(game => game.active) .sort(compareDate as any) const active_games_section = ( Now playing ) const top_games = games .sort((a, b) => ((b.rating ?? 0) - (a.rating ?? 0))) .slice(0, 10) const top_games_section = ( Top games ) const played_games = games .sort((a, b) => ((b.hours_played ?? 0) - (a.hours_played ?? 0))) .slice(0, 10) const played_games_section = ( Most played games ) const progress_games = games .sort((a, b) => -compare_progress(a, b)) .slice(0, 10) const progress_games_section = ( Most progressed games ) const latest_games = games .sort((a, b) => -compareDate(a, b)) .slice(0, 10) const latest_games_section = ( Latest updates ) const games_cols = (games.length > 0) ? ( Videogames View all Feed {active_games.length > 0 && ( {active_games_section} )} {top_games_section} {progress_games_section} {played_games_section} {latest_games_section} ) : null return ( {intro_section} {games_cols} ) }