diff --git a/api/index.js b/api/index.js
index f602a49..e04b1ad 100644
--- a/api/index.js
+++ b/api/index.js
@@ -66,6 +66,16 @@ async function fetchStats(username) {
return stats;
}
+const createTextNode = (icon, label, value, lheight) => {
+ return `
+
+ ${icon} ${label}:
+ ${value}
+ `;
+};
+
const renderSVG = (stats, options) => {
const {
name,
@@ -75,51 +85,34 @@ const renderSVG = (stats, options) => {
totalPRs,
contributedTo,
} = stats;
- const { hide, show_icons, hide_border } = options || {};
+ const { hide, show_icons, hide_border, line_height } = options || {};
+
+ const lheight = line_height || 25;
const STAT_MAP = {
- stars: `
-
- ★ Total Stars:
- ${totalStars}
- `,
- commits: `
-
- 🕗 Total Commits:
- ${totalCommits}
- `,
- prs: `
-
- 🔀 Total PRs:
- ${totalPRs}
- `,
- issues: `
-
- ⓘ Total Issues:
- ${totalIssues}
- `,
- contribs: `
- 📕 Contributed to:
- ${contributedTo} repos
- `,
+ stars: createTextNode("★", "Total Stars", totalStars, lheight),
+ commits: createTextNode("🕗", "Total Commits", totalCommits, lheight),
+ prs: createTextNode("🔀", "Total PRs", totalPRs, lheight),
+ issues: createTextNode("ⓘ", "Total Issues", totalIssues, lheight),
+ contribs: createTextNode("📕", "Contributed to", contributedTo, lheight),
};
const statItems = Object.keys(STAT_MAP)
.filter((key) => !hide.includes(key))
.map((key) => STAT_MAP[key]);
- const height = 45 + (statItems.length + 1) * 25;
+ const height = 45 + (statItems.length + 1) * lheight;
return `