kopia lustrzana https://github.com/badgen/badgen.net
feat: migrate /pub
rodzic
36240b0905
commit
6016e85e70
|
@ -25,7 +25,6 @@ export const liveBadgeList = [
|
|||
'elm-package',
|
||||
'scoop',
|
||||
'f-droid',
|
||||
'pub',
|
||||
'shards',
|
||||
'wapm',
|
||||
'snapcraft',
|
||||
|
|
|
@ -4,6 +4,7 @@ import gitlab from '../pages/api/gitlab'
|
|||
import https from '../pages/api/https'
|
||||
import amo from '../pages/api/amo'
|
||||
import npm from '../pages/api/npm'
|
||||
import pub from '../pages/api/pub'
|
||||
import crates from '../pages/api/crates'
|
||||
import docker from '../pages/api/docker'
|
||||
import bundlephobia from '../pages/api/bundlephobia'
|
||||
|
@ -30,6 +31,7 @@ export default {
|
|||
https: https.meta,
|
||||
amo: amo.meta,
|
||||
npm: npm.meta,
|
||||
pub: pub.meta,
|
||||
crates: crates.meta,
|
||||
docker: docker.meta,
|
||||
'open-vsx': openVsx.meta,
|
||||
|
|
|
@ -56,6 +56,7 @@ const nextConfig = {
|
|||
'/vs-marketplace',
|
||||
'/hackage',
|
||||
'/ppm',
|
||||
'/pub',
|
||||
'/pypi',
|
||||
// analysis
|
||||
'/bundlephobia',
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
import got from '../libs/got'
|
||||
import { millify, version, versionColor } from '../libs/utils'
|
||||
import { createBadgenHandler, BadgenError, PathArgs } from '../libs/create-badgen-handler'
|
||||
import got from '../../libs/got'
|
||||
import { millify, version, versionColor } from '../../libs/utils'
|
||||
import { createBadgenHandler, BadgenError, PathArgs } from '../../libs/create-badgen-handler-next'
|
||||
|
||||
const PUB_API_URL = 'https://pub.dev/api/'
|
||||
const PUB_REPO_URL = 'https://pub.dev/'
|
||||
|
@ -22,7 +22,7 @@ export default createBadgenHandler({
|
|||
},
|
||||
handlers: {
|
||||
'/pub/:topic<v|version|sdk-version|likes|points|popularity|dart-platform|flutter-platform>/:pkg': apiHandler,
|
||||
'/pub/:topic<license>/:pkg': webHandler
|
||||
'/pub/:topic<license>/:pkg': licenseHandler
|
||||
}
|
||||
})
|
||||
|
||||
|
@ -94,21 +94,23 @@ async function apiHandler ({ topic, pkg }: PathArgs) {
|
|||
color: platforms ? 'blue' : 'grey'
|
||||
}
|
||||
}
|
||||
default:
|
||||
return {
|
||||
subject: 'pub',
|
||||
status: 'unknown topic',
|
||||
color: 'grey'
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
async function webHandler({ topic, pkg }: PathArgs) {
|
||||
async function licenseHandler({ pkg }: PathArgs) {
|
||||
const html = await fetchPage(pkg)
|
||||
|
||||
switch (topic) {
|
||||
case 'license': {
|
||||
const license = html.match(/License<\/h3>\s*<p>[^>]+>([^(]+)\(/i)?.[1].trim()
|
||||
return {
|
||||
subject: 'license',
|
||||
status: license || 'unknown',
|
||||
color: 'blue'
|
||||
}
|
||||
}
|
||||
const license = html.match(/License<\/h3>\s*<p>[^>]+>([^(]+)\(/i)?.[1].trim()
|
||||
return {
|
||||
subject: 'license',
|
||||
status: license || 'unknown',
|
||||
color: 'blue'
|
||||
}
|
||||
}
|
||||
|
|
@ -128,10 +128,6 @@
|
|||
"source": "/packagist/:match*",
|
||||
"destination": "https://v2022.badgen.net/packagist/:match*"
|
||||
},
|
||||
{
|
||||
"source": "/pub/:match*",
|
||||
"destination": "https://v2022.badgen.net/pub/:match*"
|
||||
},
|
||||
{
|
||||
"source": "/reddit/:match*",
|
||||
"destination": "https://v2022.badgen.net/reddit/:match*"
|
||||
|
|
Ładowanie…
Reference in New Issue