kopia lustrzana https://github.com/badgen/badgen.net
badge: add Mastodon/Pleroma support (#396)
* badge: add mastodon/pleroma support * badge(mastodon): avoid description overflowpull/400/head
rodzic
558836b93c
commit
1faa455354
|
@ -0,0 +1,26 @@
|
|||
import got from '../libs/got'
|
||||
import { millify } from '../libs/utils'
|
||||
import { createBadgenHandler, PathArgs } from '../libs/create-badgen-handler'
|
||||
|
||||
export default createBadgenHandler({
|
||||
title: 'Mastodon/Pleroma',
|
||||
examples: {
|
||||
'/mastodon/follow/1': 'followers (mastodon.social)',
|
||||
'/mastodon/follow/1/mas.to': 'followers (other Mastodon instance)',
|
||||
'/mastodon/follow/1/pleroma.site': 'followers (Pleroma instance)',
|
||||
},
|
||||
handlers: {
|
||||
'/mastodon/follow/:userId/:instance?': handler
|
||||
}
|
||||
})
|
||||
|
||||
async function handler ({ userId, instance = 'mastodon.social' }: PathArgs) {
|
||||
const prefixUrl = `https://${instance}/api/v1/`
|
||||
const info = await got(`accounts/${userId}`, { prefixUrl }).json<any>()
|
||||
|
||||
return {
|
||||
subject: `follow @${info.username}@${instance}`,
|
||||
status: millify(info.followers_count),
|
||||
color: '3487CE'
|
||||
}
|
||||
}
|
|
@ -52,6 +52,7 @@ export const liveBadgeList = [
|
|||
'opencollective',
|
||||
'keybase',
|
||||
'twitter',
|
||||
'mastodon',
|
||||
'tidelift',
|
||||
'runkit',
|
||||
'https',
|
||||
|
|
Ładowanie…
Reference in New Issue