forked from mirrored/github-readme-stats
log changed as per request
This commit is contained in:
+2
-2
@@ -13,11 +13,11 @@ module.exports = async (req, res) => {
|
||||
const {
|
||||
username,
|
||||
hide,
|
||||
show_stats,
|
||||
hide_title,
|
||||
hide_border,
|
||||
hide_rank,
|
||||
show_icons,
|
||||
show_forks,
|
||||
count_private,
|
||||
include_all_commits,
|
||||
line_height,
|
||||
@@ -58,11 +58,11 @@ module.exports = async (req, res) => {
|
||||
res.send(
|
||||
renderStatsCard(stats, {
|
||||
hide: parseArray(hide),
|
||||
show_stats: parseArray(show_stats),
|
||||
show_icons: parseBoolean(show_icons),
|
||||
hide_title: parseBoolean(hide_title),
|
||||
hide_border: parseBoolean(hide_border),
|
||||
hide_rank: parseBoolean(hide_rank),
|
||||
show_forks: parseBoolean(show_forks),
|
||||
include_all_commits: parseBoolean(include_all_commits),
|
||||
line_height,
|
||||
title_color,
|
||||
|
||||
@@ -70,7 +70,7 @@ _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 comma separated values.
|
||||
To hide any specific stats, you can pass a query parameter `hide=` with comma separated values.
|
||||
|
||||
> Options: `&hide=stars,commits,prs,issues,contribs`
|
||||
|
||||
@@ -78,14 +78,18 @@ To hide any specific stats, you can pass a query parameter `?hide=` with comma s
|
||||

|
||||
```
|
||||
|
||||
### Show total forked repository count
|
||||
### Showing individual stats
|
||||
|
||||
To show forked repository count, you can pass a query parameter `show_forks=true`.
|
||||
To hide any specific stats, you can pass a query parameter `show_stats=` with comma separated values.
|
||||
|
||||
> Options: `&show_stats=stars,commits,prs,issues,contribs`
|
||||
|
||||
```md
|
||||

|
||||

|
||||
```
|
||||
|
||||
Note: `show_stats` is more prioritize than `hide`. That means if you add `prs` in both `&hide=prs` and `show_stats=prs` then pull request status will display.
|
||||
|
||||
### Adding private contributions count to total commits count
|
||||
|
||||
You can add the count of all your private contributions to the total commits count by using the query parameter `?count_private=true`.
|
||||
|
||||
+7
-11
@@ -55,12 +55,12 @@ const renderStatsCard = (stats = {}, options = { hide: [] }) => {
|
||||
} = stats;
|
||||
const {
|
||||
hide = [],
|
||||
show_stats = [],
|
||||
show_icons = false,
|
||||
hide_title = false,
|
||||
hide_border = false,
|
||||
hide_rank = false,
|
||||
include_all_commits = false,
|
||||
show_forks = false,
|
||||
line_height = 25,
|
||||
title_color,
|
||||
icon_color,
|
||||
@@ -69,6 +69,7 @@ const renderStatsCard = (stats = {}, options = { hide: [] }) => {
|
||||
theme = "default",
|
||||
} = options;
|
||||
|
||||
const new_hide = hide.concat(["forks"]);
|
||||
const lheight = parseInt(line_height, 10);
|
||||
|
||||
// returns theme based colors with proper overrides and defaults
|
||||
@@ -87,7 +88,6 @@ const renderStatsCard = (stats = {}, options = { hide: [] }) => {
|
||||
label: "Total Stars",
|
||||
value: totalStars,
|
||||
id: "stars",
|
||||
isShowEnable: true,
|
||||
},
|
||||
commits: {
|
||||
icon: icons.commits,
|
||||
@@ -96,45 +96,41 @@ const renderStatsCard = (stats = {}, options = { hide: [] }) => {
|
||||
}`,
|
||||
value: totalCommits,
|
||||
id: "commits",
|
||||
isShowEnable: true,
|
||||
},
|
||||
prs: {
|
||||
icon: icons.prs,
|
||||
label: "Total PRs",
|
||||
value: totalPRs,
|
||||
id: "prs",
|
||||
isShowEnable: true,
|
||||
},
|
||||
issues: {
|
||||
icon: icons.issues,
|
||||
label: "Total Issues",
|
||||
value: totalIssues,
|
||||
id: "issues",
|
||||
isShowEnable: true,
|
||||
},
|
||||
contribs: {
|
||||
icon: icons.contribs,
|
||||
label: "Contributed to",
|
||||
value: contributedTo,
|
||||
id: "contribs",
|
||||
isShowEnable: true,
|
||||
},
|
||||
forks: {
|
||||
icon: icons.fork,
|
||||
label: "Total Forks",
|
||||
value: totalForkRepositories,
|
||||
id: "forks",
|
||||
isShowEnable: show_forks,
|
||||
},
|
||||
};
|
||||
|
||||
// filter out hidden stats defined by user & create the text nodes
|
||||
const statItems = Object.entries(STATS)
|
||||
.filter((item) => !hide.includes(item[0]) && item[1].isShowEnable)
|
||||
.map((item, index) =>
|
||||
const statItems = Object.keys(STATS)
|
||||
.filter((key) => !new_hide.includes(key))
|
||||
.concat(show_stats)
|
||||
.map((key, index) =>
|
||||
// create the text nodes, and pass index so that we can calculate the line spacing
|
||||
createTextNode({
|
||||
...STATS[item[0]],
|
||||
...STATS[key],
|
||||
index,
|
||||
showIcons: show_icons,
|
||||
shiftValuePos: !include_all_commits,
|
||||
|
||||
@@ -211,10 +211,10 @@ describe("Test renderStatsCard", () => {
|
||||
).not.toHaveAttribute("x");
|
||||
});
|
||||
|
||||
it("should render properly with show_forks flag", () => {
|
||||
document.body.innerHTML = renderStatsCard(stats, { show_forks: false });
|
||||
it("should render properly with show_stats flag", () => {
|
||||
document.body.innerHTML = renderStatsCard(stats, {});
|
||||
expect(queryByTestId(document.body, "forks")).toBeNull();
|
||||
document.body.innerHTML = renderStatsCard(stats, { show_forks: true });
|
||||
document.body.innerHTML = renderStatsCard(stats, { show_stats: "forks,others" });
|
||||
expect(queryByTestId(document.body, "forks")).toBeDefined();
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user