diff --git a/api/index.js b/api/index.js index a3d9f2a9c0f90..d171c80f907b0 100644 --- a/api/index.js +++ b/api/index.js @@ -37,7 +37,7 @@ export default async (req, res) => { number_format, border_color, rank_icon, - show_total_reviews, + show, } = req.query; res.setHeader("Content-Type", "image/svg+xml"); @@ -96,7 +96,7 @@ export default async (req, res) => { locale: locale ? locale.toLowerCase() : null, disable_animations: parseBoolean(disable_animations), rank_icon, - show_total_reviews: parseBoolean(show_total_reviews), + show: parseArray(show), }), ); } catch (err) { diff --git a/readme.md b/readme.md index 0e843a81bac2d..a67d30979442a 100644 --- a/readme.md +++ b/readme.md @@ -88,6 +88,7 @@ Please visit [this link](https://give.do/fundraisers/stand-beside-the-victims-of - [GitHub Stats Card](#github-stats-card) - [Hiding individual stats](#hiding-individual-stats) + - [Showing additional individual stats](#showing-additional-individual-stats) - [Showing icons](#showing-icons) - [Themes](#themes) - [Customization](#customization) @@ -149,6 +150,16 @@ You can pass a query parameter `&hide=` to hide any specific stats with comma-se ![Anurag's GitHub stats](https://github-readme-stats.vercel.app/api?username=anuraghazra&hide=contribs,prs) ``` +### Showing additional individual stats + +You can pass a query parameter `&show=` to show any specific stats with comma-separated values. + +> Options: `&show=reviews` + +```md +![Anurag's GitHub stats](https://github-readme-stats.vercel.app/api?username=anuraghazra&show=reviews) +``` + ### Showing icons To enable icons, you can pass `&show_icons=true` in the query param, like so: @@ -306,7 +317,7 @@ You can provide multiple comma-separated values in the bg_color option to render - `disable_animations` - Disables all animations in the card _(boolean)_. Default: `false`. - `ring_color` - Color of the rank circle _(hex color)_. Defaults to the theme ring color if it exists and otherwise the title color. - `number_format` - Switch between two available formats for displaying the card values `short` (i.e. `6.6k`) and `long` (i.e. `6626`). Default: `short`. -- `show_total_reviews` - Show total PR reviews _(boolean)_. Default: `false`. +- `show` - Show total PR reviews _(boolean)_. Default: `false`. > **Note** > When hide_rank=`true`, the minimum card width is 270 px + the title length and padding. diff --git a/src/cards/stats-card.js b/src/cards/stats-card.js index 9b5763e8489c9..58c1de254ad0d 100644 --- a/src/cards/stats-card.js +++ b/src/cards/stats-card.js @@ -112,7 +112,7 @@ const renderStatsCard = (stats = {}, options = { hide: [] }) => { locale, disable_animations = false, rank_icon = "default", - show_total_reviews = false, + show = [], } = options; const lheight = parseInt(String(line_height), 10); @@ -161,7 +161,7 @@ const renderStatsCard = (stats = {}, options = { hide: [] }) => { id: "prs", }; - if (show_total_reviews) { + if (show.includes("reviews")) { STATS.reviews = { icon: icons.reviews, label: i18n.t("statcard.reviews"), diff --git a/src/cards/types.d.ts b/src/cards/types.d.ts index cec7b7f705308..abd7d20fa8fc2 100644 --- a/src/cards/types.d.ts +++ b/src/cards/types.d.ts @@ -27,7 +27,7 @@ export type StatCardOptions = CommonOptions & { ring_color: string; text_bold: boolean; rank_icon: RankIcon; - show_total_reviews: boolean; + show: string[]; }; export type RepoCardOptions = CommonOptions & { diff --git a/tests/renderStatsCard.test.js b/tests/renderStatsCard.test.js index 6b751d9d80a8c..6a47f944400e0 100644 --- a/tests/renderStatsCard.test.js +++ b/tests/renderStatsCard.test.js @@ -77,7 +77,7 @@ describe("Test renderStatsCard", () => { it("should show total reviews", () => { document.body.innerHTML = renderStatsCard(stats, { - show_total_reviews: true, + show: ["reviews"], }); expect(