سؤال

Using aside, I'm trying to show an edit icon to be clicked to call custom protocol with the title of the blog.

For example, when 2014-01-19-python-iteration-with-range.markdown is the markdown of the octopress blog, clicking the sidebar edit icon open://Users/doc/prg/source/_post/2014-01-19-python-iteration-with-range.markdown is invoked.

enter image description here

I modified _config.yml to have this line:

post_asides: [
    asides/edit.html
]

I also put the edit.html as follows in the asides directory.

<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>

Following the hints in this site, I tried page.path, but nothing shows up.

What variable should be filled in ??? to get the file name of the post? Or how can I know the markdown file name of the octopress post?

I thought about using {{ page.id }} and replacing / with - together with some string change can get the file path of markdown, but I don't know how to translate the name.

هل كانت مفيدة؟

المحلول

I got an answer from this site.

When page.path is not available, copy the following code into any rb file in plugin directory.

 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

And I have the link correctly.

enter image description here

مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top