Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions _config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -254,6 +254,11 @@ auto_excerpt:
enable: false
length: 150

# Post edit
post_edit:
enable: false
url:

# Post meta display settings
post_meta:
item_text: true
Expand Down
1 change: 1 addition & 0 deletions languages/_en.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ sidebar:
toc: Table of Contents

post:
edit: Edit
created: Post created
modified: Post modified
sticky: Sticky
Expand Down
1 change: 1 addition & 0 deletions languages/zh-CN.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ sidebar:
overview: 站点概览
toc: 文章目录
post:
edit: 编辑
created: 创建于
modified: 更新于
sticky: 置顶
Expand Down
7 changes: 6 additions & 1 deletion layout/_macro/post.swig
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,12 @@
<a class="post-title-link" href="{{ url_for(post.path) }}" itemprop="url">{#
#}{{ post.title | default(__('post.untitled'))}}{#
#}</a>{#
#}{% else %}{{ post.title }}{% endif %}{#
#}{% else %}
{{ post.title }}
{% if theme.post_edit.enable %}
<a href="{{theme.post_edit.url}}{{post.source.slice(7)}}" class="article-edit-link" title="{{ __('post.edit') }}"><i class="fa fa-pencil"></i></a>
Copy link
Member

@ivan-nginx ivan-nginx Apr 4, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can i ask what's mean post.source.slice(7)? I'm interesting in slice(7) parameter. Especially in number 7.

Copy link
Contributor Author

@xu-song xu-song Apr 4, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

post.source starts with _post/

in the above case

post.source = `_post/web/blog-framework/nodejs-hexo/plugin/hexo-plugin-recommendation.md`

Generally, we need to get the post path, which not include _post/ .

post.source.slice(7) = 'web/blog-framework/nodejs-hexo/plugin/hexo-plugin-recommendation.md'
post_edit.url = 'https://github.com/ESblog/_posts/tree/master/'
post_edit.url+post.source.slice(7) = 'https://github.com/ESblog/_posts/tree/master/web/blog-framework/nodejs-hexo/plugin/hexo-plugin-recommendation.md'

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am not sure whether all the post.source starts with _post/. Maybe need to be optimized.

{% endif %}
{% endif %}{#
#}{% endif %}{#
#}</{% if theme.seo %}h2{% else %}h1{% endif %}>
{% endif %}
Expand Down
11 changes: 11 additions & 0 deletions source/css/_common/components/post/post-title.styl
Original file line number Diff line number Diff line change
Expand Up @@ -31,3 +31,14 @@

.fa { font-size: 16px; }
}
.post-title .article-edit-link {
color: #bbb;
display: block;
float: right;
border-bottom: none;
}

.post-title .article-edit-link:hover {
color: black;
}