在jekyll / liquid中可以使用`include`从绝对链接/其他网址导入?

时间:2014-02-17 03:06:58

标签: jekyll liquid

例如,可能是这样的:

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

从该位置提取降价内容并呈现为jekyll布局?

1 个答案:

答案 0 :(得分:0)

是的,您可以使用Octokit API执行此操作,但您必须为此编写插件。

请参阅我的网站回购以获取示例:

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)

对于一个实例,我在这里使用它的方式:

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

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

结果如下:

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