pull/61/head
amio 2019-10-03 10:47:18 +08:00
rodzic 34c0d1e3f3
commit 9543aa138d
4 zmienionych plików z 220 dodań i 388 usunięć

589
package-lock.json wygenerowano

Plik diff jest za duży Load Diff

Wyświetl plik

@ -18,10 +18,10 @@
"prepublishOnly": "npm run build"
},
"devDependencies": {
"@zeit/ncc": "^0.20.4",
"@zeit/ncc": "^0.20.5",
"benchmark": "^2.1.4",
"serve-marked": "^2.0.2",
"standard": "^14.0.2",
"tap": "^14.6.1"
"standard": "^14.3.1",
"tap": "^14.6.9"
}
}

Wyświetl plik

@ -9,14 +9,14 @@ const badgen = require('..')
const icons = require('../test/assets/icon-data-uri.js')
const serveBadge = (req, res) => {
const { pathname, searchParams: query } = new url.URL(req.url)
const { label, style, icon, iconWidth, labelColor } = qs.parse(query)
const { pathname, query } = url.parse(req.url)
const { icon, ...queryParams } = qs.parse(query)
const [subject, status, color] = pathname.split('/').splice(1)
.map(s => qs.unescape(s))
res.statusCode = 200
res.setHeader('Content-Type', 'image/svg+xml;charset=utf-8')
res.end(badgen({ label, labelColor, subject, status, color, style, icon: icons[icon], iconWidth }))
res.end(badgen({ subject, status, color, icon: icons[icon], ...queryParams }))
}
const md = fs.readFileSync(path.join(__dirname, 'preview.md'), 'utf8')

Wyświetl plik

@ -12,7 +12,8 @@ module.exports = ({
style,
icon,
iconWidth = 13,
labelColor = '555'
labelColor = '555',
scale = 1
}) => {
typeAssert(typeof status === 'string', '<status> must be string')
@ -38,7 +39,7 @@ module.exports = ({
status = sanitize(status)
if (style === 'flat') {
return `<svg width="${width / 10}" height="20" viewBox="0 0 ${width} 200" xmlns="http://www.w3.org/2000/svg"${xlink}>
return `<svg width="${scale * width / 10}" height="${scale * 20}" viewBox="0 0 ${width} 200" xmlns="http://www.w3.org/2000/svg"${xlink}>
<g>
<rect fill="#${labelColor}" width="${sbRectWidth}" height="200"/>
<rect fill="#${color}" x="${sbRectWidth}" width="${stRectWidth}" height="200"/>
@ -53,7 +54,7 @@ module.exports = ({
</svg>`
}
return `<svg width="${width / 10}" height="20" viewBox="0 0 ${width} 200" xmlns="http://www.w3.org/2000/svg"${xlink}>
return `<svg width="${scale * width / 10}" height="${scale * 20}" viewBox="0 0 ${width} 200" xmlns="http://www.w3.org/2000/svg"${xlink}>
<linearGradient id="a" x2="0" y2="100%">
<stop offset="0" stop-opacity=".1" stop-color="#EEE"/>
<stop offset="1" stop-opacity=".1"/>