kopia lustrzana https://github.com/badgen/badgen
Update bench & preview for emoji support
rodzic
daad4723a4
commit
f24eb68b2b
|
@ -3,11 +3,13 @@ const badgen = require('..')
|
|||
|
||||
const longParams = { subject: 'build-build-build', status: 'passing-passing-passing' }
|
||||
const fullParams = { subject: 'license', status: 'MIT', color: 'cyan' }
|
||||
const emojiParams = { subject: 'emojis', status: '💩🤱🦄' }
|
||||
|
||||
new Suite()
|
||||
.add('[classic] style, long params ', () => badgen(longParams))
|
||||
.add('[classic] style, full params ', () => badgen(fullParams))
|
||||
.add(' [flat] style, long params ', () => badgen({ style: 'flat', ...longParams }))
|
||||
.add(' [flat] style, full params ', () => badgen({ style: 'flat', ...fullParams }))
|
||||
.add('[classic] style, multi bytes ', () => badgen(emojiParams))
|
||||
.on('cycle', event => console.log(String(event.target)))
|
||||
.run()
|
||||
|
|
|
@ -29,3 +29,10 @@
|
|||
| | [/style/standard/f2a/flat](/style/standard/f2a/flat) |
|
||||
| | [/license/Apache-2.0/blue/flat](/license/Apache-2.0/blue/flat) |
|
||||
| | [/Language/Swift%203.0.1/orange/flat](/Language/Swift%203.0.1/orange/flat) |
|
||||
|
||||
## Multibytes unicode
|
||||
|
||||
| Badge | URL |
|
||||
| --- | --- |
|
||||
| | [/emoji/💩🤱🦄/cyan/flat?unicode=1](/emoji/💩🤱🦄/cyan/flat?unicode=1) |
|
||||
| | [/emoji/💩🤱🦄/cyan/?unicode=1](/emoji/💩🤱🦄/cyan/?unicode=1) |
|
||||
|
|
|
@ -7,12 +7,13 @@ const badgen = require('..')
|
|||
// @example
|
||||
// http://localhost:3000/npm/v1.2.3
|
||||
const serveBadge = (req, res) => {
|
||||
const unicode = Boolean(qs.parse(req.url.split('?')[1]).unicode)
|
||||
const [ subject, status, color, style ] = req.url.split('/')
|
||||
.filter(Boolean)
|
||||
.map(s => qs.unescape(s))
|
||||
|
||||
res.writeHead(200, { 'Content-Type': 'image/svg+xml;charset=utf-8' })
|
||||
res.end(badgen({subject, status, color, style}))
|
||||
res.end(badgen({subject, status, color, style, unicode}))
|
||||
}
|
||||
|
||||
// @example
|
||||
|
|
Ładowanie…
Reference in New Issue