From cc558e4d7c938631870a1a167068829a7ef15ade Mon Sep 17 00:00:00 2001 From: Zohan Subhash Date: Sun, 15 Jan 2023 16:01:17 +0530 Subject: [PATCH] Update top-langs.js --- api/wild/top-langs.js | 43 ++++++++++++++++++++++++++----------------- 1 file changed, 26 insertions(+), 17 deletions(-) diff --git a/api/wild/top-langs.js b/api/wild/top-langs.js index a1c9a2e5..3092b619 100644 --- a/api/wild/top-langs.js +++ b/api/wild/top-langs.js @@ -28,23 +28,32 @@ export default async (req, res) => { res.setHeader("Content-Type", "image/svg+xml"); try { - const topLangs = req.query.top_langs ? req.query.top_langs.split(",") : [ - { - name: "Javascript", - size: 50, - color: "#4287f5", - }, - { - name: "Python", - size: 30, - color: "#eb4034", - }, - { - name: "Ruby", - size: 20, - color: "#32a852", - } - ]; + let topLangs = [] + if (req.query.top_langs) { + const split = req.query.top_langs.split(","); + split.forEach(lang => { + topLangs.push(JSON.parse(lang)) + }); + } else { + topLangs = [ + { + name: "Javascript", + size: 50, + color: "#4287f5", + }, + { + name: "Python", + size: 30, + color: "#eb4034", + }, + { + name: "Ruby", + size: 20, + color: "#32a852", + } + ]; + } + const title = req.query.title || "Most Used Languages"; const cacheSeconds = clampValue(