mirror of
https://github.com/dilllxd/gitfolio.git
synced 2024-08-14 22:28:09 +00:00
added star sort
This commit is contained in:
parent
ed5ca7a8b6
commit
9a10b06385
3 changed files with 22 additions and 11 deletions
|
@ -49,10 +49,10 @@ $ node build --name username -f
|
|||
|
||||
#### Sorting Repos
|
||||
|
||||
To sort repos provide `--sort [sortBy]` argument while building. Where `[sort]` can be `created`, `updated`, `pushed`,`full_name`. Default: `created`
|
||||
To sort repos provide `--sort [sortBy]` argument while building. Where `[sort]` can be `star`, `created`, `updated`, `pushed`,`full_name`. Default: `created`
|
||||
|
||||
```
|
||||
$ node build --name username --sort created
|
||||
$ node build --name username --sort star
|
||||
```
|
||||
|
||||
#### Ordering Repos
|
||||
|
@ -60,7 +60,7 @@ $ node build --name username --sort created
|
|||
To order the sorted repos provide `--order [orderBy]` argument while building. Where `[orderBy]` can be `asc` or `desc`. Default: `asc`
|
||||
|
||||
```
|
||||
$ node build --name username --sort created --order desc
|
||||
$ node build --name username --sort star --order desc
|
||||
```
|
||||
|
||||
#### Customize Themes
|
||||
|
|
8
build.js
8
build.js
|
@ -74,14 +74,10 @@ populateCSS();
|
|||
|
||||
if (program.name) {
|
||||
let sort = program.sort ? program.sort : 'created';
|
||||
let order = -1;
|
||||
let order = "asc";
|
||||
let includeFork = false;
|
||||
|
||||
if(program.order){
|
||||
if(program.order === 'asc')
|
||||
order = 1;
|
||||
else if(program.order === 'desc')
|
||||
order = -1;
|
||||
order = ('%s', program.order);
|
||||
}
|
||||
if(program.fork){
|
||||
includeFork = true;
|
||||
|
|
17
populate.js
17
populate.js
|
@ -34,8 +34,23 @@ module.exports.updateHTML = (username, sort, order, includeFork) => {
|
|||
(async () => {
|
||||
try {
|
||||
console.log("Building HTML/CSS...");
|
||||
var repos = await got(`https://api.github.com/users/${username}/repos?sort=${sort}&order=${order}&per_page=1200`);
|
||||
var repos;
|
||||
if(sort == "star"){
|
||||
repos = await got(`https://api.github.com/users/${username}/repos?per_page=1200`);
|
||||
repos = JSON.parse(repos.body);
|
||||
if(order == "desc"){
|
||||
repos = repos.sort(function(a, b) {
|
||||
return b.stargazers_count - a.stargazers_count;
|
||||
});
|
||||
}else{
|
||||
repos = repos.sort(function(a, b) {
|
||||
return a.stargazers_count - b.stargazers_count;
|
||||
});
|
||||
}
|
||||
}else{
|
||||
repos = await got(`https://api.github.com/users/${username}/repos?sort=${sort}&order=${order}&per_page=1200`);
|
||||
repos = JSON.parse(repos.body);
|
||||
}
|
||||
for (var i = 0; i < repos.length; i++) {
|
||||
if(repos[i].fork == false){
|
||||
document.getElementById("work_section").innerHTML += `
|
||||
|
|
Loading…
Reference in a new issue