Browse Source

live-fns: add twitter #206

docker-size
Amio 6 years ago
parent
commit
7e1fa1a0d1
  1. 10
      libs/index.md
  2. 1
      libs/live-fns/_index.js
  3. 21
      libs/live-fns/twitter.js

10
libs/index.md

@ -255,7 +255,7 @@ Advanced usage (for badge makers):
'lgtm': [
['number of alerts', '/lgtm/alerts/g/apache/cloudstack'],
['java code quality', '/lgtm/grade/java/g/apache/cloudstack'],
['C/C++ code quality', '/lgtm/grade/cpp/g/systemd/systemd'],
['C/C++ code quality', '/lgtm/grade/cpp/g/systemd/systemd']
],
'uptime robot': [
['status', '/uptime-robot/status/m780862024-50db2c44c703e5c68d6b1ebb'],
@ -280,7 +280,7 @@ Advanced usage (for badge makers):
['hits (per month)', '/jsdelivr/hits/gh/jquery/jquery'],
['hits (per month)', '/jsdelivr/hits/npm/lodash'],
['rank', '/jsdelivr/rank/npm/lodash'],
['version', '/jsdelivr/v/npm/lodash'],
['version', '/jsdelivr/v/npm/lodash']
],
'azure pipelines': [
['build', '/azure-pipelines/yarnpkg/yarn/Yarn Acceptance Tests'],
@ -291,11 +291,15 @@ Advanced usage (for badge makers):
['backers', '/opencollective/backers/webpack'],
['contributors', '/opencollective/contributors/webpack'],
['balance', '/opencollective/balance/webpack'],
['yearly income', '/opencollective/yearly/webpack'],
['yearly income', '/opencollective/yearly/webpack']
],
keybase: [
['pgp', '/keybase/pgp/lukechilds']
],
twitter: [
['follower count', '/twitter/follow/rustlang'],
['follower count', '/twitter/follow/golang']
]
}
window.links = {

1
libs/live-fns/_index.js

@ -30,6 +30,7 @@ module.exports = {
rubygems: require('./rubygems.js'),
runkit: require('./runkit.js'),
travis: require('./travis.js'),
twitter: require('./twitter.js'),
'uptime-robot': require('./uptime-robot.js'),
'vs-marketplace': require('./vs-marketplace.js'),
xo: require('./xo')

21
libs/live-fns/twitter.js

@ -0,0 +1,21 @@
const got = require('../got.js')
const millify = require('millify')
module.exports = async (topic, user) => {
const endpoint = `http://cdn.syndication.twimg.com/widgets/followbutton/info.json?screen_names=${user}`
const [info] = await got(endpoint).then(res => res.body)
switch (topic) {
case 'follow':
return {
subject: `follow @${user}`,
status: millify(info.followers_count),
color: '1da1f2'
}
default:
return {
subject: `twitter`,
status: `unknown topic`
}
}
}
Loading…
Cancel
Save