mirror of
https://github.com/tycrek/degoogle
synced 2024-11-12 01:11:03 +00:00
Added GitHub Stars badge to build script (resolves #418)
This commit is contained in:
parent
4fd9023a48
commit
c384610c2a
15
_build.js
15
_build.js
@ -93,6 +93,9 @@ function generateServiceSection(data) {
|
||||
// Append the Repo badge to the name
|
||||
if (item.repo) name = name.concat('<br/>', repoLink(item.repo));
|
||||
|
||||
// Append the Star badge to the name
|
||||
if (item.repo) name = name.concat('<br/>', starBadge(item.repo));
|
||||
|
||||
// Build the row
|
||||
const tableItem = `| ${name} | ${eyes} | ${text} |${EOL}`;
|
||||
|
||||
@ -122,6 +125,18 @@ function repoLink(repo) {
|
||||
return `[![Repo](https://img.shields.io/badge/open-source-3DA639?style=flat-square&logo=${repoHost})](${repo})`;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a badge displaying the number of GitHub Stars for a repository.
|
||||
* @param {String} repo The repository url
|
||||
*/
|
||||
function starBadge(repo) {
|
||||
if (repo.startsWith('https://github.com/')) {
|
||||
const [user, repoName] = repo.split('github.com/')[1].split('/');
|
||||
if (!repoName || repoName === '') return '';
|
||||
return `![GitHub Repo stars](https://img.shields.io/github/stars/${user}/${repoName}?logo=github&style=flat-square)`;
|
||||
} else return '';
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a badge displaying user for a Firefox addon/extension
|
||||
* @param {String} link URL to extension WITHOUT trailing slash
|
||||
|
Loading…
Reference in New Issue
Block a user