@@ -12,9 +12,10 @@ const BUNDLEPHOBIA_API = 'https://bundlephobia.com/api/size'
1212const NPMS_API = 'https://api.npms.io/v2/package'
1313
1414const QUERY_SCHEMA = v . object ( {
15- colorA : v . optional ( v . string ( ) ) ,
15+ color : v . optional ( v . string ( ) ) ,
1616 name : v . optional ( v . string ( ) ) ,
17- colorB : v . optional ( v . string ( ) ) ,
17+ labelColor : v . optional ( v . string ( ) ) ,
18+ label : v . optional ( v . string ( ) ) ,
1819} )
1920
2021const COLORS = {
@@ -263,9 +264,10 @@ export default defineCachedEventHandler(
263264 } )
264265
265266 const queryParams = v . safeParse ( QUERY_SCHEMA , query )
266- const userColor = queryParams . success ? queryParams . output . colorB : undefined
267- const userColorLeft = queryParams . success ? queryParams . output . colorA : undefined
267+ const userColor = queryParams . success ? queryParams . output . color : undefined
268+ const labelColor = queryParams . success ? queryParams . output . labelColor : undefined
268269 const showName = queryParams . success && queryParams . output . name === 'true'
270+ const userLabel = queryParams . success ? queryParams . output . label : undefined
269271
270272 const badgeTypeResult = v . safeParse ( BadgeTypeSchema , typeParam )
271273 const strategyKey = badgeTypeResult . success ? badgeTypeResult . output : 'version'
@@ -276,13 +278,13 @@ export default defineCachedEventHandler(
276278 const pkgData = await fetchNpmPackage ( packageName )
277279 const strategyResult = await strategy ( pkgData , requestedVersion )
278280
279- const finalLabel = showName ? packageName : strategyResult . label
281+ const finalLabel = userLabel ? userLabel : showName ? packageName : strategyResult . label
280282 const finalValue = strategyResult . value
281283
282284 const rawColor = userColor ?? strategyResult . color
283285 const finalColor = rawColor ?. startsWith ( '#' ) ? rawColor : `#${ rawColor } `
284286
285- const rawLeftColor = userColorLeft ?? '#0a0a0a'
287+ const rawLeftColor = labelColor ?? '#0a0a0a'
286288 const finalLeftColor = rawLeftColor ?. startsWith ( '#' ) ? rawLeftColor : `#${ rawLeftColor } `
287289
288290 const leftWidth = measureTextWidth ( finalLabel )
0 commit comments