Giter Club home page Giter Club logo

jekyll-github-sample's Introduction

jekyll-github-sample

Two Jekyll Liquid tags to display a code sample from a file in a public Github repo and provide a reference to it.

Install

  • First add the gem to your Gemfile
gem 'jekyll_github_sample'
  • bundle to install the gem
  • Add the gem to your Jekyll _config.yml
gems: [jekyll_github_sample]
  • Startup or relaunch Jekyll

Live Examples

A write up on my Jekyll blog including samples referencing this repo's code, meta.

github_sample Usage

{% github_sample URL_WITH_USERNAME_REPO_AND_FILE <START_LINE_NUMBER> <END_LINE_NUMBER> %}
  • URL_WITH_USERNAME_REPO_AND_FILE - the relative path to the Github repo file, prefer a file with the commitish in it so it won't change when recompiling occurs. A url to this README would be: bwillis/jekyll-github-sample/blob/a3bc9e82412d364aa76e9308ab53ff2bddaa2faf/README.md
  • START_LINE_NUMBER - (optional) number that is the first line to include (0 based)
  • END_LINE_NUMBER - (optional) number that is the last line to include, if excluded will read to end of file

github_sample_ref Usage

{% github_sample_ref URL_WITH_USERNAME_REPO_AND_FILE %}
  • URL_WITH_USERNAME_REPO_AND_FILE - the relative path to the Github repo file, prefer a file with the commitish in it so it won't change when recompiling occurs. A url to this README would be: bwillis/jekyll-github-sample/blob/a3bc9e82412d364aa76e9308ab53ff2bddaa2faf/README.md

Example Usage

This is how you would display, reference and highlight code in your Jekyll post.

{% github_sample_ref /bwillis/versioncake/989237901cb873f96df12be48cbf1239be496bd7/Appraisals %}
{% highlight ruby %}
{% github_sample /bwillis/versioncake/989237901cb873f96df12be48cbf1239be496bd7/Appraisals 0 5 %}
{% endhighlight %}

Thanks!

Thanks to all those who have helped make this really awesome:

License

Jekyll Github Sample is released under the MIT license: www.opensource.org/licenses/MIT

jekyll-github-sample's People

Contributors

bwillis avatar heedfull avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.