Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/bwillis/jekyll-github-sample
:bookmark_tabs: Get a sample of a Github public repo file
https://github.com/bwillis/jekyll-github-sample
Last synced: about 1 month ago
JSON representation
:bookmark_tabs: Get a sample of a Github public repo file
- Host: GitHub
- URL: https://github.com/bwillis/jekyll-github-sample
- Owner: bwillis
- Created: 2014-05-28T21:14:31.000Z (over 10 years ago)
- Default Branch: master
- Last Pushed: 2023-03-17T02:34:16.000Z (over 1 year ago)
- Last Synced: 2024-10-11T13:49:57.872Z (2 months ago)
- Language: Ruby
- Homepage:
- Size: 32.2 KB
- Stars: 59
- Watchers: 5
- Forks: 18
- Open Issues: 11
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
- awesome-jekyll-plugins - **GitHub Sample Tag** - - A liquid tag to include a sample of a github repo file in your Jekyll site. (Tags)
README
# 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
1. Add the gem to your `Gemfile`.
```ruby
gem 'jekyll_github_sample'
```
1. Install.
```sh
bundle install
1. Add the gem to your Jekyll `_config.yml`.
```yaml
plugins:
- jekyll_github_sample
```
1. Start Jekyll.## Live Examples
A [write up](https://bwillis.github.io/2014/05/28/include-github-repo-code-in-jekyll/) on my Jekyll blog including samples referencing this repo's code, meta.
## github_sample Usage
```liquid
{% github_sample 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`
* 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 fileOne can also specify the lines to include based on markings in the file itself.
This is done by invoking```liquid
{% github_sample URL_WITH_USERNAME_REPO_AND_FILE tag:TAG_NAME %}
```And placing the strings `[START TAG_NAME]` and `[END TAG_NAME]` anywhere in the lines immediately before and after the content you wish to include.
## github_sample_ref Usage
```liquid
{% 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.
```liquid
{% 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:
* [heedfull](https://github.com/heedfull)
* [robertwb](https://github.com/robertwb)## License
Jekyll Github Sample is released under the [MIT license](https://www.opensource.org/licenses/MIT).