* refactor(githubforks): convert to static fields * refactor(githubgomod): convert to static fields * refactor(githubissuedetail): convert to static fields * refactor(githubissues): convert to static fields * refactor(githublabels): convert to static fields * refactor(githublanguagecount): convert to static fields * refactor(githublastcommit): convert to static fields Co-authored-by: Paul Melnikow <github@paulmelnikow.com>
35 lines
849 B
JavaScript
35 lines
849 B
JavaScript
'use strict'
|
|
|
|
const { BaseGithubLanguage } = require('./github-languages-base')
|
|
const { documentation } = require('./github-helpers')
|
|
|
|
module.exports = class GithubLanguageCount extends BaseGithubLanguage {
|
|
static category = 'analysis'
|
|
static route = { base: 'github/languages/count', pattern: ':user/:repo' }
|
|
static examples = [
|
|
{
|
|
title: 'GitHub language count',
|
|
namedParams: {
|
|
user: 'badges',
|
|
repo: 'shields',
|
|
},
|
|
staticPreview: this.render({ count: 5 }),
|
|
documentation,
|
|
},
|
|
]
|
|
|
|
static defaultBadgeData = { label: 'languages' }
|
|
|
|
static render({ count }) {
|
|
return {
|
|
message: count,
|
|
color: 'blue',
|
|
}
|
|
}
|
|
|
|
async handle({ user, repo }) {
|
|
const data = await this.fetch({ user, repo })
|
|
return this.constructor.render({ count: Object.keys(data).length })
|
|
}
|
|
}
|