From 6fa963b76ed68d3cfb1cb3317df16ed63e6152e7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=28=27o=20mo=29y-=CB=9C?= Date: Mon, 11 Apr 2022 00:42:22 +0900 Subject: [PATCH] exclude by rank (#132) * exclude by rank * Add a description of the ranks --- README.md | 7 +++++++ src/trophy_list.ts | 6 ++++++ 2 files changed, 13 insertions(+) diff --git a/README.md b/README.md index 9d5df93..9475a0e 100644 --- a/README.md +++ b/README.md @@ -140,6 +140,13 @@ If you want to specify multiple ranks. https://github-profile-trophy.vercel.app/?username=ryo-ma&rank=S,AAA ``` +You can also exclude ranks. + +``` +https://github-profile-trophy.vercel.app/?username=ryo-ma&rank=-C,-B +``` + + ## Specify the maximum row & column size You can specify the maximum row and column size. diff --git a/src/trophy_list.ts b/src/trophy_list.ts index d317f6c..b9eaa35 100644 --- a/src/trophy_list.ts +++ b/src/trophy_list.ts @@ -58,6 +58,12 @@ export class TrophyList { }); } filterByRanks(ranks: Array) { + if (ranks.filter((rank) => rank.includes("-")).length !== 0) { + this.trophies = this.trophies.filter((trophy) => + !ranks.map(rank => rank.substring(1)).includes(trophy.rank) + ) + return + } this.trophies = this.trophies.filter((trophy) => ranks.includes(trophy.rank) );