A Jekyll widget for Github Repo Cards

This Jekyll widget can render a Github repo card on a Jekyll page.

Usage

Place this include on a post or page, passing in the name of a public repo you own in the reponame parameter.

{% include repo_card.html reponame="gpslogger" %}

The above will render this:

:satellite: Lightweight GPS Logging Application For Android. Available on the Android Market as "GPSLogger for Android"

Adding to your own Jekyll site

You will need to copy the include template, and the sass styling as well.

_include/repo-card.html _sass/github-repo-card.scss

I am using the minimal-mistakes theme, which includes Font Awesome for the icons. You may have to tweak the scss for your own themes.

Background

While learning how to work with Jekyll, and the minimal mistakes theme, I came across a page on Github describing the repository metadata available.

A list of your own repositories are available in site.github.public_repositories along with things like description, stars and forks.

The trick is to filter out to only grab the repo matching the name passed in.

{% assign repository = site.github.public_repositories 
| where: "name", include.reponame 
| first %}%

Then it’s a simple matter of using repository in the liquid template HTML.

Updated: