Question

for example, could something like:

{% include https://raw.github.com/propublica/guides/master/coding-manifesto.md %}

pull in markdown content from that location and be rendered into a jekyll layout?

Was it helpful?

Solution

Yes, you can do that using Octokit API, but you will have to write plugin for that.

See my site repo for an example:

module Jekyll
  class OctokitContents < Liquid::Tag
    def initialize(tag_name, text, tokens)
      super
      @temp=text.split(';')
    end
    def render(context)
        @address = "madhur/"+"#{@temp[0]}"

     cred = YAML.load_file("d:/github.yml")
      client = Octokit::Client.new(:login => cred[":username"], :password => cred[":password"])

       puts "Getting Github Contents via octokit.rb " + @address + @temp[1]
       out=client.contents @address, :accept => 'application/vnd.github.html', :path =>  @temp[1]
       out
    end
  end
end
Liquid::Template.register_tag('octokit_contents', Jekyll::OctokitContents)

For a live example, here how I used it here:

{% octokit_contents SPProjects;OrgChart/Readme.markdown%}

https://raw2.github.com/madhur/madhur.github.com/source/projects/Silverlight%20Organization%20Chart%20for%20SharePoint.md

Here is the result:

http://www.madhur.co.in/projects/Silverlight%20Organization%20Chart%20for%20SharePoint.html

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top