diff --git a/api/top-langs.js b/api/top-langs.js
index 5899d9d..6c6634c 100644
--- a/api/top-langs.js
+++ b/api/top-langs.js
@@ -1,11 +1,17 @@
require("dotenv").config();
-const { renderError, clampValue, CONSTANTS } = require("../src/utils");
+const {
+ renderError,
+ clampValue,
+ parseBoolean,
+ CONSTANTS,
+} = require("../src/utils");
const fetchTopLanguages = require("../src/fetchTopLanguages");
const renderTopLanguages = require("../src/renderTopLanguages");
module.exports = async (req, res) => {
const {
username,
+ hide_title,
card_width,
title_color,
text_color,
@@ -34,6 +40,7 @@ module.exports = async (req, res) => {
res.send(
renderTopLanguages(topLangs, {
theme,
+ hide_title: parseBoolean(hide_title),
card_width: parseInt(card_width, 10),
title_color,
text_color,
diff --git a/src/renderTopLanguages.js b/src/renderTopLanguages.js
index 608afbe..a8f5eb7 100644
--- a/src/renderTopLanguages.js
+++ b/src/renderTopLanguages.js
@@ -7,17 +7,31 @@ const createProgressNode = ({ width, color, name, progress }) => {
const progressPercentage = clampValue(progress, 2, 100);
return `
- ${name}
+ ${name}
${progress}%
`;
};
const renderTopLanguages = (topLangs, options = {}) => {
- const { title_color, text_color, bg_color, theme, card_width } = options;
+ const {
+ hide_title,
+ card_width,
+ title_color,
+ text_color,
+ bg_color,
+ theme,
+ } = options;
const langs = Object.values(topLangs);
@@ -34,8 +48,11 @@ const renderTopLanguages = (topLangs, options = {}) => {
});
const width = isNaN(card_width) ? 300 : card_width;
- const height = 45 + (langs.length + 1) * 40;
+ let height = 45 + (langs.length + 1) * 40;
+ if (hide_title) {
+ height -= 30;
+ }
return `