2014-03-04 133 views
0

撇开,我试图显示一个编辑图标被点击以调用自定义协议与博客的标题。我如何知道Octopress中帖子的降价文件名?

例如,当2014年1月19日 - python的迭代与 - range.markdown是octopress博客的降价,点击边栏编辑图标开放://用户/ DOC/PRG /源/_post/2014-01-19-python-iteration-with-range.markdown被调用。

enter image description here

我修改_config.yml有这样一行:

post_asides: [ 
    asides/edit.html 
] 

我也把edit.html作为旁白目录如下。

<section class="googleplus{% if site.googleplus_hidden %} googleplus-hidden{% endif %}"> 
    <h1> 
    <a href="open:///Users/doc/prg/source/_posts/{{ ??? }}"> 
     <img src="/images/self_edit.png" width="32" height="32"> 
     Edit 
    </a> 
    </h1> 
</section> 

this site的提示,我试过page.path,但没有显示出来。

应填写什么变量?获取帖子的文件名? 或者我怎么能知道octopress文章的降价文件名?

我曾考虑过使用{{page.id}}并替换/ with - 一起更改字符串可以获得markdown的文件路径,但我不知道如何翻译名称。

回答

0

我从this site得到了答案。

当page.path不可用时,将以下代码复制到插件目录中的任何rb文件中。

class PagePathGenerator < Generator 
    safe true 
    ## See post.dir and post.base for directory information. 
    def generate(site) 
     site.posts.each do |post| 
     post.data['path'] = post.name 
     end 

    end 
    end 

而且我有正确的链接。

enter image description here

+0

这对Jekyll 3.0及以上版本无效......任何想法? –

相关问题