kopia lustrzana https://github.com/badgen/badgen.net
feat: add docker icon & examples #26
rodzic
ae6a843eda
commit
72f58b0c4b
|
@ -0,0 +1,20 @@
|
|||
const fs = require('fs')
|
||||
const { join, parse } = require('path')
|
||||
|
||||
const icons = {}
|
||||
|
||||
fs.readdirSync(join(__dirname, 'icons')).forEach(filename => {
|
||||
const imageType = {
|
||||
'.svg': 'svg+xml',
|
||||
'.png': 'png'
|
||||
}[parse(filename).ext]
|
||||
|
||||
if (!imageType) return
|
||||
|
||||
const key = parse(filename).name
|
||||
const b64 = fs.readFileSync(join(__dirname, 'icons', filename)).toString('base64')
|
||||
|
||||
icons[key] = `data:image/${imageType};base64,${b64}`
|
||||
})
|
||||
|
||||
module.exports = icons
|
|
@ -0,0 +1 @@
|
|||
<svg xmlns="http://www.w3.org/2000/svg" height="189" width="221.667"><defs><clipPath id="a"><path d="M0 141.75h166.25V0H0z"/></clipPath><clipPath id="b"><path d="M0 141.75h166.25V0H0z"/></clipPath></defs><g clip-path="url(#a)" transform="matrix(1.33333 0 0 -1.33333 0 189)"><path d="M94.268 76.204h15.743v14.312H94.268zm-18.605 0h15.742v14.312H75.663zm-18.605 0h15.743v14.312H57.058zm-18.605 0h15.743v14.312H38.453zm-18.605 0h15.743v14.312H19.848zm18.605 17.173h15.743v14.311H38.453zm18.605 0h15.743v14.311H57.058zm18.605 0h15.742v14.311H75.663zm0 17.174h15.742v14.312H75.663zm81.658-26.003c-3.438 2.3-11.338 3.143-17.417 1.997-.783 5.726-3.974 10.691-9.779 15.179l-3.337 2.225-2.227-3.34c-2.851-4.299-4.275-10.256-3.808-15.967.21-2.01.87-5.603 2.937-8.764-2.066-1.11-6.15-2.64-11.533-2.537H8.622l-.203-1.192c-.973-5.74-.952-23.653 10.678-37.42 8.84-10.464 22.094-15.772 39.392-15.772 37.5 0 65.244 17.263 78.237 48.641 5.109-.102 16.109-.03 21.76 10.766.147.248.486.896 1.473 2.942l.541 1.122z" fill="#ffffff" fill-rule="evenodd"/></g><g clip-path="url(#b)" transform="matrix(1.33333 0 0 -1.33333 0 189)"><path d="M104.137 24.241h.216c.252 0 .456.084.456.288 0 .18-.132.3-.42.3-.12 0-.204-.012-.252-.024zm-.012-1.115h-.456v1.967c.18.036.432.06.756.06.372 0 .539-.06.684-.144a.547.547 0 0 0 .19-.432c0-.216-.167-.384-.406-.455v-.025c.19-.072.3-.215.359-.479.06-.3.096-.42.145-.492h-.492c-.06.072-.096.252-.157.48-.035.216-.155.312-.407.312h-.216zm-1.212 1.032c0-.876.649-1.57 1.536-1.57.864 0 1.499.694 1.499 1.557 0 .876-.635 1.583-1.511 1.583-.875 0-1.524-.707-1.524-1.57m3.538 0c0-1.116-.875-1.99-2.014-1.99-1.127 0-2.027.874-2.027 1.99 0 1.091.9 1.967 2.027 1.967 1.139 0 2.014-.876 2.014-1.967" fill="#ffffff"/></g></svg>
|
Po Szerokość: | Wysokość: | Rozmiar: 1.7 KiB |
|
@ -78,6 +78,10 @@ Available color names:
|
|||
| david-dm dev dependencies |  | [/david/dev/zeit/pkg](/david/dev/zeit/pkg)
|
||||
| david-dm peer dependencies |  | [/david/peer/epoberezkin/ajv-keywords](/david/peer/epoberezkin/ajv-keywords)
|
||||
| david-dm optional dependencies |  | [/david/optional/epoberezkin/ajv-keywords](/david/optional/epoberezkin/ajv-keywords)
|
||||
| docker pulls (library) |  | [/docker/pulls/library/ubuntu](/docker/pulls/library/ubuntu)
|
||||
| docker stars (library) |  | [/docker/stars/library/ubuntu](/docker/stars/library/ubuntu)
|
||||
| docker pulls (scoped) |  | [/docker/pulls/amio/node-chrome](/docker/pulls/amio/node-chrome)
|
||||
| docker stars (icon & label) |  | [/docker/stars/library/mongo?icon=docker&label=stars](/docker/stars/library/mongo?icon=docker&label=stars)
|
||||
| packagephobia publish size |  | [/packagephobia/publish/webpack](/packagephobia/publish/webpack)
|
||||
| packagephobia install size |  | [/packagephobia/install/webpack](/packagephobia/install/webpack)
|
||||
| uptime robot status |  | [/uptime-robot/status/m780731617-a9e038618dc1aee36a44c4af](/uptime-robot/status/m780731617-a9e038618dc1aee36a44c4af)
|
||||
|
|
|
@ -1,19 +1,21 @@
|
|||
const { send } = require('micro')
|
||||
const badgen = require('badgen')
|
||||
const icons = require('./icons.js')
|
||||
|
||||
module.exports = function serveBadge (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, emoji, list } = req.query
|
||||
const { style, label, emoji, list, icon } = req.query
|
||||
|
||||
const badgenParams = {
|
||||
subject: String(label || subject),
|
||||
status: String(list ? status.replace(/,/g, ' | ') : status),
|
||||
color: color,
|
||||
style: style || hostStyle,
|
||||
emoji: !!emoji
|
||||
emoji: Boolean(emoji),
|
||||
icon: icons[icon] || icon
|
||||
}
|
||||
|
||||
res.setHeader('Content-Type', 'image/svg+xml;charset=utf-8')
|
||||
|
|
Ładowanie…
Reference in New Issue