kopia lustrzana https://github.com/badgen/badgen
Update preview
rodzic
66acafbb1b
commit
6202601514
|
@ -8,6 +8,7 @@
|
|||
"scripts": {
|
||||
"lint": "standard",
|
||||
"bench": "node bench/index.js",
|
||||
"preview": "node test/serve-preview.js",
|
||||
"test": "tap test/*.spec.js --reporter spec",
|
||||
"start": "node service.js",
|
||||
"predeploy": "now rm badgen --safe -y -T badgen",
|
||||
|
|
|
@ -19,3 +19,4 @@
|
|||
|![](http://localhost:3000/chat/gitter/purple) | http://localhost:3000/chat/gitter/purple |
|
||||
|![](http://localhost:3000/style/standard/f2a) | http://localhost:3000/style/standard/f2a |
|
||||
|![](http://localhost:3000/license/Apache-2.0/blue) | http://localhost:3000/license/Apache-2.0/blue |
|
||||
|![](http://localhost:3000/Language/Swift%203.0.1/orange) | http://localhost:3000/Language/Swift%203.0.1/orange |
|
||||
|
|
|
@ -1,12 +1,16 @@
|
|||
const http = require('http')
|
||||
const path = require('path')
|
||||
const qs = require('querystring')
|
||||
const serveMarked = require('serve-marked')
|
||||
const badgen = require('..')
|
||||
|
||||
// @example
|
||||
// http://localhost:3000/npm/v1.2.3
|
||||
const serveBadge = (req, res) => {
|
||||
const [ subject, status, color ] = req.url.split('/').filter(Boolean)
|
||||
const [ subject, status, color ] = 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}))
|
||||
}
|
||||
|
@ -29,9 +33,7 @@ const serveIndex = serveMarked(md, {
|
|||
|
||||
http.createServer((req, res) => {
|
||||
switch (req.url) {
|
||||
case '/':
|
||||
return serveIndex(req, res)
|
||||
default:
|
||||
return serveBadge(req, res)
|
||||
case '/': return serveIndex(req, res)
|
||||
default: return serveBadge(req, res)
|
||||
}
|
||||
}).listen(3000)
|
Ładowanie…
Reference in New Issue