kopia lustrzana https://github.com/badgen/badgen.net
Support custom list separator
rodzic
59f854d4af
commit
75313a6980
|
@ -17,9 +17,12 @@ export default function (req, res, options: ServeBadgeOptions) {
|
|||
const { label, list, icon, iconWidth } = query
|
||||
const _icon = resolveIcon(icon === '' ? subject : icon, iconWidth)
|
||||
|
||||
// TODO: review usage of list
|
||||
list && console.log(`FEAT:LIST ${req.url}`)
|
||||
|
||||
const badge = badgen({
|
||||
subject: typeof label !== 'undefined' ? label : subject,
|
||||
status: list ? String(status).replace(/,/g, ' | ') : String(status),
|
||||
status: transformStatus(status, { list }),
|
||||
color: query.color || color,
|
||||
style: query.style || process.env.BADGE_STYLE,
|
||||
icon: _icon.src,
|
||||
|
@ -34,6 +37,17 @@ export default function (req, res, options: ServeBadgeOptions) {
|
|||
res.end(badge)
|
||||
}
|
||||
|
||||
function transformStatus (status: any, { list }) {
|
||||
status = String(status)
|
||||
|
||||
if (list !== undefined) {
|
||||
if (list === '1') list = '|' // compatible
|
||||
status = status.replace(/,/g, ` ${list} `)
|
||||
}
|
||||
|
||||
return status
|
||||
}
|
||||
|
||||
type ResolvedIcon = {
|
||||
src?: string
|
||||
width?: string
|
||||
|
|
Ładowanie…
Reference in New Issue