2014-03-04 122 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及以上版本無效......任何想法? –

相關問題