kopia lustrzana https://github.com/badgen/badgen.net
Better handle style switch
rodzic
f22b13c458
commit
2773a5cce6
|
@ -47,10 +47,10 @@ export function badgenServe (handlers: BadgenServeHandlers): Function {
|
|||
params.subject = simpleDecode(params.subject)
|
||||
params.status = simpleDecode(params.status)
|
||||
|
||||
if (query.style === undefined
|
||||
&& process.env.BADGE_STYLE === 'flat'
|
||||
|| req.headers.host.startsWith('flat')) {
|
||||
query.style = 'flat'
|
||||
if (query.style === undefined) {
|
||||
if ((req.headers[':authority'] || req.headers.host).startsWith('flat')) {
|
||||
query.style = 'flat'
|
||||
}
|
||||
}
|
||||
|
||||
return serveBadge(req, res, { params, query })
|
||||
|
|
|
@ -14,7 +14,8 @@ export default function (req, res, options: ServeBadgeOptions) {
|
|||
const { code = 200, sMaxAge = 10800, query = {}, params } = options
|
||||
|
||||
const { subject, status, color } = params
|
||||
const { style, label, list, icon, iconWidth, color: queryColor } = query
|
||||
const { label, list, icon, iconWidth } = query
|
||||
|
||||
const _icon = icons[icon === '' ? subject : icon] || {
|
||||
base64: icon,
|
||||
width: iconWidth
|
||||
|
@ -22,9 +23,9 @@ export default function (req, res, options: ServeBadgeOptions) {
|
|||
|
||||
const badge = badgen({
|
||||
subject: typeof label !== 'undefined' ? label : subject,
|
||||
status: String(list ? status.replace(/,/g, ' | ') : status),
|
||||
color: queryColor || color,
|
||||
style: style,
|
||||
status: list ? String(status).replace(/,/g, ' | ') : String(status),
|
||||
color: query.color || color,
|
||||
style: query.style || process.env.BADGE_STYLE,
|
||||
icon: _icon.base64,
|
||||
iconWidth: _icon.width
|
||||
})
|
||||
|
|
Ładowanie…
Reference in New Issue