From 06cad8b682d8882a4850c4d5425ced50a78c90ed Mon Sep 17 00:00:00 2001 From: Amio Date: Fri, 31 Aug 2018 14:19:40 +0800 Subject: [PATCH] docs: put lgtm icon in examples --- libs/index.md | 2 +- libs/serve-badge.js | 9 +++++++-- package-lock.json | 6 +++--- package.json | 2 +- 4 files changed, 12 insertions(+), 7 deletions(-) diff --git a/libs/index.md b/libs/index.md index 36f3acd..f66d46a 100644 --- a/libs/index.md +++ b/libs/index.md @@ -296,7 +296,7 @@ Advanced usage (for badge makers): fetch('/metadata.json') .then((resp) => resp.json()) .then(json => { - const blacklist = ['npm-red', 'postgresql', 'discord', 'lgtm'] + const blacklist = ['npm-red', 'postgresql', 'discord'] const icons = document.querySelector('#icon-examples') for (const icon of json.icons) { if (blacklist.indexOf(icon) !== -1) continue; diff --git a/libs/serve-badge.js b/libs/serve-badge.js index f2c99c4..3e6447d 100644 --- a/libs/serve-badge.js +++ b/libs/serve-badge.js @@ -3,13 +3,17 @@ const { send } = require('micro') const { builtin } = require('./icons.js') const CACHE_CONTROL = `public, max-age=60, stale-while-revalidate=86400, stale-if-error=86400` +const noneSquareIconWidths = { + codeclimate: 18, + lgtm: 19 +} module.exports = (req, res, options = {}) => { const { code = 200, maxAge = '86400' } = options const hostStyle = req.headers.host === 'flat.badgen.net' ? 'flat' : undefined const { subject, status, color } = req.params - const { style, label, list, icon } = req.query + const { style, label, list, icon, iconWidth } = req.query const badge = badgen({ subject: typeof label !== 'undefined' ? label : subject, @@ -17,7 +21,8 @@ module.exports = (req, res, options = {}) => { color: color, style: style || hostStyle, emoji: true, - icon: builtin[icon] + icon: builtin[icon], + iconWidth: iconWidth || noneSquareIconWidths[icon] }) res.setHeader('Content-Type', 'image/svg+xml;charset=utf-8') diff --git a/package-lock.json b/package-lock.json index 283b349..239a18f 100644 --- a/package-lock.json +++ b/package-lock.json @@ -252,9 +252,9 @@ } }, "badgen": { - "version": "2.4.4", - "resolved": "https://registry.npmjs.org/badgen/-/badgen-2.4.4.tgz", - "integrity": "sha512-B8Kns0nemOOIwndUGQ8YFHHfoxhsYUh8EsktjBvn9uwLj7CzaMRthvi99zCGE8a0v5s+/c8qRZz2EaJUxXy2xg==" + "version": "2.4.5", + "resolved": "https://registry.npmjs.org/badgen/-/badgen-2.4.5.tgz", + "integrity": "sha512-fGCNEZm2pF/DuCnqK8IKNRkwEZ6NWU6FeKQKgjMLyB2ht4URcaU2vla5L2N78W99lAKJIlwwJ4ZGoJw9fAd+9w==" }, "balanced-match": { "version": "1.0.0", diff --git a/package.json b/package.json index 84e2078..eebcec6 100644 --- a/package.json +++ b/package.json @@ -17,7 +17,7 @@ }, "dependencies": { "axios": "^0.18.0", - "badgen": "^2.4.4", + "badgen": "^2.4.5", "byte-size": "^4.0.3", "cheerio": "^1.0.0-rc.2", "chrome-webstore": "^1.0.0",