diff --git a/api/index.js b/api/index.js
index d951d71..6343f5d 100644
--- a/api/index.js
+++ b/api/index.js
@@ -16,6 +16,9 @@ async function fetchStats(username) {
repositoriesContributedTo(first: 100, contributionTypes: [COMMIT, ISSUE, PULL_REQUEST, REPOSITORY]) {
totalCount
}
+ contributionsCollection {
+ totalCommitContributions
+ }
pullRequests(first: 100) {
totalCount
}
@@ -41,6 +44,7 @@ async function fetchStats(username) {
const stats = {
name: "",
totalPRs: 0,
+ totalCommits: 0,
totalIssues: 0,
totalStars: 0,
contributedTo: 0,
@@ -51,6 +55,7 @@ async function fetchStats(username) {
stats.name = user.name;
stats.totalIssues = user.issues.totalCount;
+ stats.totalCommits = user.contributionsCollection.totalCommitContributions;
stats.totalPRs = user.pullRequests.totalCount;
stats.contributedTo = user.repositoriesContributedTo.totalCount;
@@ -62,43 +67,66 @@ async function fetchStats(username) {
}
const renderSVG = (stats, options) => {
- const { name, totalStars, totalIssues, totalPRs, contributedTo } = stats;
- const { hide } = options || {};
- const height = 150 - hide.length * 20;
+ const {
+ name,
+ totalStars,
+ totalCommits,
+ totalIssues,
+ totalPRs,
+ contributedTo,
+ } = stats;
+ const { hide, show_icons } = options || {};
const STAT_MAP = {
stars: `
- Total Stars:
- ${totalStars}
+
+ ★ Total Stars:
+ ${totalStars}
+ `,
+ commits: `
+
+ 🕗 Total Commits:
+ ${totalCommits}
`,
prs: `
- Total PRs:
- ${totalPRs}
+
+ 🔀 Total PRs:
+ ${totalPRs}
`,
issues: `
- Total Issues:
- ${totalIssues}
+
+ ⓘ Total Issues:
+ ${totalIssues}
`,
contribs: `
- Contributed to:
- ${contributedTo} repos
+ 📕 Contributed to:
+ ${contributedTo} repos
`,
};
+ const statItems = Object.keys(STAT_MAP)
+ .filter((key) => !hide.includes(key))
+ .map((key) => STAT_MAP[key]);
+
+ const height = 45 + (statItems.length + 1) * 25;
+
return `
`;
@@ -107,9 +135,11 @@ const renderSVG = (stats, options) => {
module.exports = async (req, res) => {
const username = req.query.username;
const hide = req.query.hide;
+ const show_icons = req.query.show_icons;
let {
name,
totalPRs,
+ totalCommits,
totalStars,
totalIssues,
contributedTo,
@@ -121,11 +151,12 @@ module.exports = async (req, res) => {
{
name,
totalStars,
+ totalCommits,
totalIssues,
totalPRs,
contributedTo,
},
- { hide: JSON.parse(hide || "[]") }
+ { hide: JSON.parse(hide || "[]"), show_icons }
)
);
};
diff --git a/readme.md b/readme.md
index 02788ef..eba58f3 100644
--- a/readme.md
+++ b/readme.md
@@ -22,14 +22,28 @@ To hide any specific stats you can pass a query parameter `?hide=` with an array

```
+### Showing icons
+
+To enable icons you can pass `show_icons=true` in the query param like so
+
+```md
+
+```
+
## Demo
+- Default
+

- Hiding specific stats

+- Showing icons
+
+
+
Contributions are welcomed! <3
Made with :heart: and javascript.