Skip to content

Instantly share code, notes, and snippets.

@jasalt
Last active January 29, 2023 07:32
Show Gist options
  • Save jasalt/91ee171ba9b41aad0dbf2c6cd1eaf10f to your computer and use it in GitHub Desktop.
Save jasalt/91ee171ba9b41aad0dbf2c6cd1eaf10f to your computer and use it in GitHub Desktop.
HTML / JS to embed Github starred repos on web site [WordPress Compatible]
<script src="https://code.jquery.com/jquery-3.6.0.js" integrity="sha256-H+K7U5CnXl1h5ywQfKtSj8PCmoN9aaq30gDh27Xc0jk=" crossorigin="anonymous"></script>
<div class="gh-starred-repos"></div>
<script>
var urlToGetLatestStarredRepos = "https://api.github.com/users/jasalt/starred?per_page=10";
jQuery(document).ready(function () {
jQuery.getJSON(urlToGetLatestStarredRepos, function (allRepos) {
jQuery.each(allRepos, function (i, repo) {
var repoUrl = jQuery('<a style="color:red;"></a>').text(repo.full_name).attr('href', repo.html_url).appendTo(".gh-starred-repos");
jQuery(".gh-starred-repos").append("<label> [" + repo.description + "]</label>" + " <i><strong>" + repo.language + "</strong> ⭐ " + repo.stargazers_count + " </i> ");
});
});
});
</script>
@jasalt
Copy link
Author

jasalt commented Jan 29, 2023

Ready to be inserted to Custom HTML block on WordPress page. Used in https://saltiolabs.com as example.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment