mirror of
https://github.com/reiyua/github-profile-trophy-reiyua-mirror.git
synced 2026-11-17 06:02:09 +11:00
Include a query where the user can exclude trophies based on title (#276)
* First step to developing a feature to exclude speicifc trophies by title * Added support for exclusion by title * Ran deno lint, deno format and deno test found in CONTRIBUTING * Documented the latest addition in the README * Updated README
This commit is contained in:
parent
4672f2d285
commit
c48eee9e0a
3 changed files with 23 additions and 1 deletions
|
|
@ -124,6 +124,12 @@ If you want to specify multiple titles.
|
|||
https://github-profile-trophy.vercel.app/?username=ryo-ma&title=Stars,Followers
|
||||
```
|
||||
|
||||
You can also exclude the trophies you don't want to display.
|
||||
|
||||
```
|
||||
https://github-profile-trophy.vercel.app/?username=ryo-ma&title=-Stars,-Followers
|
||||
```
|
||||
|
||||
## Filter by ranks
|
||||
|
||||
You can filter the display by specifying the ranks.\
|
||||
|
|
|
|||
|
|
@ -29,7 +29,13 @@ export class Card {
|
|||
trophyList.filterByHidden();
|
||||
|
||||
if (this.titles.length != 0) {
|
||||
trophyList.filterByTitles(this.titles);
|
||||
const includeTitles = this.titles.filter((title) =>
|
||||
!title.startsWith("-")
|
||||
);
|
||||
if (includeTitles.length > 0) {
|
||||
trophyList.filterByTitles(includeTitles);
|
||||
}
|
||||
trophyList.filterByExclusionTitles(this.titles);
|
||||
}
|
||||
|
||||
if (this.ranks.length != 0) {
|
||||
|
|
|
|||
|
|
@ -76,6 +76,16 @@ export class TrophyList {
|
|||
ranks.includes(trophy.rank)
|
||||
);
|
||||
}
|
||||
filterByExclusionTitles(titles: Array<string>) {
|
||||
const excludeTitles = titles.filter((title) => title.startsWith("-")).map(
|
||||
(title) => title.substring(1),
|
||||
);
|
||||
if (excludeTitles.length > 0) {
|
||||
this.trophies = this.trophies.filter((trophy) =>
|
||||
!excludeTitles.includes(trophy.title)
|
||||
);
|
||||
}
|
||||
}
|
||||
sortByRank() {
|
||||
this.trophies = this.trophies.toSorted((a: Trophy, b: Trophy) =>
|
||||
RANK_ORDER.indexOf(a.rank) - RANK_ORDER.indexOf(b.rank)
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue