From 420bda82022fdfac5ee86253b41d3be7b3e2e0f3 Mon Sep 17 00:00:00 2001 From: tresabhi <43380238+tresabhi@users.noreply.github.com> Date: Sun, 10 Nov 2024 22:59:34 -0600 Subject: [PATCH] feat: popular tanks --- packages/website/src/pages/index.astro | 36 ++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) diff --git a/packages/website/src/pages/index.astro b/packages/website/src/pages/index.astro index ccbfcb38e..e4b365a98 100644 --- a/packages/website/src/pages/index.astro +++ b/packages/website/src/pages/index.astro @@ -1,7 +1,9 @@ --- +import { fetchAverageDefinitions, fetchTankDefinitions } from '@blitzkit/core'; import { Box, Flex, Heading } from '@radix-ui/themes'; import HomeHero from '../components/HomeHero.astro'; import { Plugs } from '../components/Plugs.tsx'; +import { TankCard } from '../components/TankSearch/components/TankCard'; import ToolCard from '../components/ToolCard.astro'; import { compareTool, @@ -14,6 +16,26 @@ import { tankopediaTool, } from '../constants/tools'; import BaseLayout from '../layouts/BaseLayout.astro'; + +const tankDefinitions = await fetchTankDefinitions(); +const averageDefinitions = await fetchAverageDefinitions(); +const tanks = Object.values(tankDefinitions.tanks); +const tankAverages = Object.entries(averageDefinitions.averages).map( + ([id, average]) => ({ + id: Number(id), + ...average, + }), +); + +// lol don't ask questions +const testTanks = tanks + .filter((tank) => tank.testing && tank.tier >= 8) + .sort((a, b) => b.tier - a.tier); +const mostPlayedTanks = tankAverages + .sort((a, b) => b.samples.d_1 - a.samples.d_1) + .map(({ id }) => tankDefinitions.tanks[id]) + .filter(Boolean); +const popularTanks = [...testTanks, ...mostPlayedTanks].slice(0, 8); --- @@ -25,6 +47,20 @@ import BaseLayout from '../layouts/BaseLayout.astro'; + + Popular tanks + + + { + popularTanks.map((tank) => ( + + + + )) + } + + + {/* */}