This is a small script that allows you to show your GitHub repos in a styled fashion showing the latest commits and a link to GitHub Pages. It is written in Vanilla JavaScript, uses the GitHub API and allorigins.win to get around the CORS issues.
All you need to use it, is include the script in your page:
<script src="github-include.js"></script>
You can use plain HTML and style it yourself, or use a web component with a dark/light mode.
<div class="github-include" data-commits="5" data-pages="π" data-links="true"> <a href="https://github.com/codepo8/mastodon-share"> Mastodon Share </a> </div>
<github-include commits="5" pages="π" links="true"> <a href="https://github.com/codepo8/mastodon-share"> Mastodon Share </a> </github-include>
<github-include commits="10" loadingmessage="fetching data" commitheader="Actions:" pages="See online"> <a href="https://github.com/codepo8/a11y-demos"> Accessibility demos </a> </github-include>
Each of these attributes can be set and overridden. When using the web component, they are the names as listed. In the HTML case, you need to prepend them with `data-`
When the script runs, it will generate the following HTML:
<div class="github-include" data-commits="5" data-pages="π" data-links="true"> <a href="https://github.com/codepo8/mastodon-share" class="github-include-origin"> Mastodon Share </a> <a class="github-include-pages" href="https://codepo8.github.io/mastodon-share/">π</a> <p class="github-include-commitheader">Latest commits: </p> <ul class="github-include-commits"> <li> <a href="https://github β¦ 4065">cleanup</a> </li> β¦ </ul> </div>