diff --git a/api/pin.js b/api/pin.js index 8a58668..6cfade4 100644 --- a/api/pin.js +++ b/api/pin.js @@ -1,6 +1,12 @@ const axios = require("axios"); require("dotenv").config(); +function kFormatter(num) { + return Math.abs(num) > 999 + ? Math.sign(num) * (Math.abs(num) / 1000).toFixed(1) + "k" + : Math.sign(num) * Math.abs(num); +} + async function fetchRepo(username, reponame) { const res = await axios({ url: "https://api.github.com/graphql", @@ -64,6 +70,7 @@ const renderRepoCard = (repo) => { const { name, description, primaryLanguage, stargazers, forkCount } = repo; const height = 120; + const shiftText = primaryLanguage.name.length > 15 ? 0 : 30; return ` `; };