Merge pull request #265 from teaxyz/truncate-stars

0.0k Format for Stargazers + Release Version Display
This commit is contained in:
Thomas Smith 2023-01-12 13:01:24 -05:00 committed by GitHub
commit 8f5a1a0a18
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 26 additions and 22 deletions

View file

@ -15,7 +15,7 @@
<ul class="list-group list-group-flush"> <ul class="list-group list-group-flush">
<a class="list-group-item" role="button" href="https://twitter.com/teaxyz"><i class="icon-twitter social-icon"></i>Twitter</a> <a class="list-group-item" role="button" href="https://twitter.com/teaxyz"><i class="icon-twitter social-icon"></i>Twitter</a>
<a class="list-group-item" role="button" href="https://discord.gg/KCZsXfJphn"><i class="icon-discord social-icon"></i>Discord</a> <a class="list-group-item" role="button" href="https://discord.gg/KCZsXfJphn"><i class="icon-discord social-icon"></i>Discord</a>
<a class="list-group-item" role="button" href="https://github.com/teaxyz"><i class="icon-github social-icon"></i>GitHub <span style="font-size:16px;">(&#9734;<span id="starcount"></span>)</span></a> <a class="list-group-item" role="button" href="https://github.com/teaxyz/cli"><i class="icon-github social-icon"></i>GitHub <span style="font-size:16px;">(&#9734;<span class="stargazers"></span>, <span class="release"></span>)</span></a>
<a class="list-group-item" role="button" href="https://t.me/tea_xyz"><i class="icon-telegram social-icon"></i>Telegram</a> <a class="list-group-item" role="button" href="https://t.me/tea_xyz"><i class="icon-telegram social-icon"></i>Telegram</a>
</ul> </ul>
</div> </div>
@ -178,25 +178,27 @@ integrity="sha384-ka7Sk0Gln4gmtz2MlQnikT1wXgYsOg+OMhuP+IlRH9sENBO0LRn5q+8nbTov4+
</script> </script>
<script> <script>
function getStarcount(repo, resultElement) { $(document).ready(function() {
var repo = 'teaxyz/cli'; var repository = "teaxyz/cli";
var url = 'https://api.github.com/repos/' + repo; var url = "https://api.github.com/repos/" + repository;
axios.get(url)
.then(function (response) { $.get(url, function(data) {
console.log(response.data.stargazers_count); var stargazers = numeral(data.stargazers_count).format("0.0a");
document.getElementById('starcount').innerHTML=response.data.stargazers_count; $(".stargazers").html(stargazers);
document.getElementById('starcount2').innerHTML=response.data.stargazers_count; });
resultElement.innerHTML = response.data.stargazers_count;
})
.catch(function (error) {
console.log(error);
}); });
} </script>
function repo() { <script>
var repo = 'teaxyz/cli';
getStarcount(repo, starcount); $(document).ready(function() {
} var repository = "teaxyz/cli";
var url = "https://api.github.com/repos/"+ repository +"/releases/latest";
document.addEventListener('DOMContentLoaded', repo());
$.get(url, function(data) {
var release = data.tag_name;
$(".release").html(release);
});
});
</script> </script>

View file

@ -113,5 +113,7 @@
<script src="https://unpkg.com/axios/dist/axios.min.js"></script> <script src="https://unpkg.com/axios/dist/axios.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/numeral.js/2.0.6/numeral.min.js"></script>
</head> </head>
</head> </head>

View file

@ -13,7 +13,7 @@
</li> </li>
{{ end }} {{ end }}
<li class="nav-item mt-lg-0 mt-md-0 mt-sm-3 mt-3"> <li class="nav-item mt-lg-0 mt-md-0 mt-sm-3 mt-3">
<a class="nav-link" aria-current="page" href="https://github.com/teaxyz">GITHUB (&#9734;<span id="starcount2"></span>)</a> <a class="nav-link" aria-current="page" href="https://github.com/teaxyz/cli">GITHUB (&#9734;<span class="stargazers"></span>, <span class="release"></span>)</a>
</li> </li>
</ul> </ul>
<!-- <!--