From 5fcd547c3d870e1fdf577ccaf8b21fabc6ffeb0d Mon Sep 17 00:00:00 2001 From: tree Date: Fri, 26 Jan 2024 02:29:26 +0100 Subject: [PATCH] fix leaderboard --- src/layouts/base.astro | 2 +- src/pages/leaderboard.astro | 50 ++++++++++++++++++++++++++++++++----- 2 files changed, 45 insertions(+), 7 deletions(-) diff --git a/src/layouts/base.astro b/src/layouts/base.astro index 4600cac..c7ff2bc 100644 --- a/src/layouts/base.astro +++ b/src/layouts/base.astro @@ -88,7 +88,7 @@ import cfonts from 'cfonts';
{/**/} -
{cfonts.render(title + ' ', { font: '', maxLength: 1000 }).string}
+
{cfonts.render(title + ' ', { font: '', maxLength: 1500 }).string}
} diff --git a/src/pages/leaderboard.astro b/src/pages/leaderboard.astro index 4b88d52..bc9d30b 100644 --- a/src/pages/leaderboard.astro +++ b/src/pages/leaderboard.astro @@ -3,23 +3,61 @@ import BaseLayout from '../layouts/base.astro'; import contributors from '../contributors.json'; +const points = {} +let i = 0; +for (const c of contributors) { + const key = `c:${c.contributions}` + if (!points[key]) { + points[key] = { arr: [c.login], start: i } + } else { + points[key].arr.push(c.login) + } + i++ +} + +function getPoint (num){ + const key = `c:${num}` + const obj = points[key]; + return `${obj.start+1}${obj.arr.length > 1 ? '-'+(obj.start+1+obj.arr.length) : ''}`; +} + --- -
- +
+ +
+ - + - {contributors.map((contrib) => ( + {contributors.map((contrib, i) => ( - - + + + ))}
Contributor# Contribs# Contributions
{contrib.login} + {[getPoint(contrib.contributions)].map((r) => ( +
+ {r < 3 && + + {r === "1" && "🥇"} + {r === "2" && "🥈"} + {r === "3" && "🥉"} + + } + {r}. +
+ ))} +
+ {contrib.login} + {contrib.contributions}