Unverified Commit aa44bd76 authored by Anurag Hazra's avatar Anurag Hazra Committed by GitHub
Browse files

fix: hide parameter array implementation (#162)

* fix: hide paramter array implementation

* chore: parseArray str check

* docs: updated readme

* chore: add codecov threshold

* docs: update docs
parent c2adcfd6
Loading
Loading
Loading
Loading
+2 −2
Original line number Diff line number Diff line
@@ -2,7 +2,7 @@ require("dotenv").config();
const {
  renderError,
  parseBoolean,
  parseJSON,
  parseArray,
  clampValue,
  CONSTANTS,
} = require("../src/utils");
@@ -45,7 +45,7 @@ module.exports = async (req, res) => {

  res.send(
    renderStatsCard(stats, {
      hide: parseJSON(hide),
      hide: parseArray(hide),
      show_icons: parseBoolean(show_icons),
      hide_title: parseBoolean(hide_title),
      hide_border: parseBoolean(hide_border),
+2 −2
Original line number Diff line number Diff line
@@ -3,7 +3,7 @@ const {
  renderError,
  clampValue,
  parseBoolean,
  parseJSON,
  parseArray,
  CONSTANTS,
} = require("../src/utils");
const fetchTopLanguages = require("../src/fetchTopLanguages");
@@ -44,7 +44,7 @@ module.exports = async (req, res) => {
      theme,
      hide_title: parseBoolean(hide_title),
      card_width: parseInt(card_width, 10),
      hide: parseJSON(hide),
      hide: parseArray(hide),
      title_color,
      text_color,
      bg_color,
+3 −0
Original line number Diff line number Diff line
@@ -7,4 +7,7 @@ coverage:
  range: "70...100"

  status:
    project:
      default:
        threshold: 5
    patch: false
+22 −22
Original line number Diff line number Diff line
@@ -57,12 +57,12 @@ _Note: Ranks are calculated based on user's stats, see [src/calculateRank.js](./

### Hiding individual stats

To hide any specific stats, you can pass a query parameter `?hide=` with an array of items you wanna hide.
To hide any specific stats, you can pass a query parameter `?hide=` with comma seperated values.

> Options: `&hide=["stars","commits","prs","issues","contribs"]`
> Options: `&hide=stars,commits,prs,issues,contribs`

```md
![Anurag's github stats](https://github-readme-stats.vercel.app/api?username=anuraghazra&hide=["contribs","prs"])
![Anurag's github stats](https://github-readme-stats.vercel.app/api?username=anuraghazra&hide=contribs,prs])
```

### Showing icons
@@ -98,13 +98,13 @@ You can customize the appearance of your `Stats Card` or `Repo Card` however you
Customization Options:

| Option        | type      | description                          | Stats Card (default) | Repo Card (default) | Top Lang Card (default) |
| ------------- | ---------- | -------------------------------------- | -------------------- | ------------------- | ----------------------- |
| ------------- | --------- | ------------------------------------ | -------------------- | ------------------- | ----------------------- |
| title_color   | hex color | title color                          | 2f80ed               | 2f80ed              | 2f80ed                  |
| text_color    | hex color | body color                           | 333                  | 333                 | 333                     |
| icon_color    | hex color | icon color                           | 4c71f2               | 586069              | 586069                  |
| bg_color      | hex color | card bg color                        | FFFEFE               | FFFEFE              | FFFEFE                  |
| line_height   | number    | control the line-height between text | 30                   | N/A                 | N/A                     |
| hide          | JSON array | hides the items specified on the array | []                   | N/A                 | []                      |
| hide          | CSV       | hides the items specified            | undefined            | N/A                 | undefined               |
| hide_rank     | boolean   | hides the ranking                    | false                | N/A                 | N/A                     |
| hide_title    | boolean   | hides the stats title                | false                | N/A                 | false                   |
| hide_border   | boolean   | hides the stats card border          | false                | N/A                 | N/A                     |
@@ -157,10 +157,10 @@ Endpoint: `api/top-langs?username=anuraghazra`

### Hide individual languages

You can use `?hide=["language1","language2"]` parameter to hide languages below a specified threshold percentage.
You can use `?hide=language1,language2` parameter to hide individual languages.

```md
[![Top Langs](https://github-readme-stats.vercel.app/api/top-langs/?username=anuraghazra&hide=["javascript","html"])](https://github.com/anuraghazra/github-readme-stats)
[![Top Langs](https://github-readme-stats.vercel.app/api/top-langs/?username=anuraghazra&hide=javascript,html])](https://github.com/anuraghazra/github-readme-stats)
```

### Demo
@@ -177,11 +177,11 @@ You can use `?hide=["language1","language2"]` parameter to hide languages below

- Hiding specific stats

![Anurag's github stats](https://github-readme-stats.vercel.app/api?username=anuraghazra&hide=["contribs","issues"])
![Anurag's github stats](https://github-readme-stats.vercel.app/api?username=anuraghazra&hide=contribs,issues])

- Showing icons

![Anurag's github stats](https://github-readme-stats.vercel.app/api?username=anuraghazra&hide=["issues"]&show_icons=true)
![Anurag's github stats](https://github-readme-stats.vercel.app/api?username=anuraghazra&hide=issues&show_icons=true)

- Themes

+4 −7
Original line number Diff line number Diff line
@@ -44,12 +44,9 @@ function parseBoolean(value) {
  }
}

function parseJSON(str) {
  try {
    return JSON.parse(str);
  } catch (err) {
    return [];
  }
function parseArray(str) {
  if (!str) return [];
  return str.split(",");
}

function clampValue(number, min, max) {
@@ -141,7 +138,7 @@ module.exports = {
  encodeHTML,
  isValidHexColor,
  request,
  parseJSON,
  parseArray,
  parseBoolean,
  fallbackColor,
  FlexLayout,
Loading