import { getI18n } from "@/lib/i18n"; import type { Metadata } from "next"; import Link from "next/link"; import { ArrowLeft, ArrowRight, Search } from "lucide-react"; import { Header, Footer } from "@/components/Shell"; import { LeaderboardEmpty, LeaderboardTable, WinnersPodium, } from "@/components/Leaderboard"; import { PixelTrophy } from "@/components/PixelArt"; import { leaderboard } from "@/lib/leaderboard"; import { user } from "@/lib/supabase"; import { leaderboardDifficulties, leaderboardFilters, leaderboardHref, } from "@/shared/leaderboard"; export const dynamic = "force-dynamic"; export async function generateMetadata(): Promise { const { t } = await getI18n(); return { title: t("Leaderboard"), description: t( "Meet MineGeo’s top explorers. Compare the best five-round scores across easy, normal, and hard Minecraft expeditions.", ), }; } export default async function LeaderboardPage({ searchParams, }: { searchParams: Promise>; }) { const { t, formatNumber } = await getI18n(); const { difficulty, search, page } = leaderboardFilters(await searchParams); const [data, account] = await Promise.all([ leaderboard({ difficulty, search, page }), user(), ]); return ( <>
{t("Back to home")}
{t("THE EXPLORERS’ BOARD")}

{t("Every block counts.")}

{t("The sharpest eyes in the Overworld.")}
{t("Five rounds. 25,000 possible points. Where do you stand?")}

{t("All time")}
{data ? ( <> {data.leaders.length > 0 && !search && data.page === 1 && ( )}

{t("The rankings")}

{t("Players: {players} · Completed expeditions: {games}", { players: formatNumber(data.total_players), games: formatNumber(data.total_games), })}

{difficulty !== "all" && ( )}
{search && (
{t("Results for “{search}”: {count}", { search, count: formatNumber(data.matching_players), })} {t("Clear search ×")}
)} {data.entries.length ? ( ) : ( )} {data.matching_players > 0 && (
{t("Showing")} {formatNumber((data.page - 1) * 25 + 1)}– {formatNumber( Math.min(data.page * 25, data.matching_players), )}{" "} {t("of")} {formatNumber(data.matching_players)}
)}
) : ( )}