kopia lustrzana https://github.com/badgen/badgen.net
rodzic
fc8bf4cc70
commit
2fa35aa4e6
11
api/opam.ts
11
api/opam.ts
|
@ -1,5 +1,5 @@
|
|||
import got from '../libs/got'
|
||||
import { millify, version, versionColor } from '../libs/utils'
|
||||
import { version, versionColor } from '../libs/utils'
|
||||
import { createBadgenHandler, PathArgs } from '../libs/create-badgen-handler'
|
||||
|
||||
const OPAM_REPO_URL = 'https://opam.ocaml.org/packages/'
|
||||
|
@ -9,7 +9,6 @@ export default createBadgenHandler({
|
|||
examples: {
|
||||
'/opam/v/merlin': 'version',
|
||||
'/opam/v/ocamlformat': 'version',
|
||||
'/opam/dm/lwt': 'monthly downloads',
|
||||
'/opam/license/cohttp': 'license'
|
||||
},
|
||||
handlers: {
|
||||
|
@ -37,13 +36,5 @@ async function handler ({ topic, pkg }: PathArgs) {
|
|||
color: 'blue'
|
||||
}
|
||||
}
|
||||
case 'dm': {
|
||||
const downloads = Number(html.match(/<th>statistics<\/th>\s*<td>installed\s*<strong>([^<]+)<\//i)?.[1])
|
||||
return {
|
||||
subject: 'downloads',
|
||||
status: millify(downloads) + '/month',
|
||||
color: 'green'
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Ładowanie…
Reference in New Issue