[new feature] add post edit button#208
[new feature] add post edit button#208ivan-nginx merged 4 commits intotheme-next:masterfrom xu-song:master
Conversation
layout/_macro/post.swig
Outdated
| #}{% 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> |
There was a problem hiding this comment.
Can i ask what's mean post.source.slice(7)? I'm interesting in slice(7) parameter. Especially in number 7.
There was a problem hiding this comment.
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'There was a problem hiding this comment.
I am not sure whether all the post.source starts with _post/. Maybe need to be optimized.
URL settingurl setting depends on the 1. For site repositorye.g. https://github.com/hexojs/hexo-starter we can set url:https://github.com/hexojs/hexo-starter/tree/master/source/_posts/ # view
# url:https://github.com/hexojs/hexo-starter/edit/master/source/_posts/ # edit2. For post repositorye.g. https://github.com/ESblog/_posts we can set url:https://github.com/ESblog/_posts/tree/master/ # view
# url:https://github.com/ESblog/_posts/edit/master/ # edit ImplementationWe need a way that works for both the above cases. Thus Maybe a better way, a more general way can be used. |
|
Ooh, i see. It's cutted out main Github link of repository, right? |
|
Yes. Any suggestion and optimization is welcome. |
|
Need upload resource md? |
|
Yes.
|
1. Disable post edit option by default. 2. Aligment post header to center with edit button enabled. 3. Add conditional import in post edit styles.
* new feature: post edit * Updated feature for post edit. * Remove excess blank lines.
PR Checklist
Please check if your PR fulfills the following requirements:
PR Type
What kind of change does this PR introduce?
What is the new behavior?
Add
editbutton for each post.It provides a way of
online edit. In addition, links to github is a good way forcollaborative edit.How it looks?
common style

hover style

Live demo here.
How to use?
In NexT
_config.yml:The above demo page, links to
https://github.com/ESblog/_posts/tree/master/web/blog-framework/nodejs-hexo/plugin/hexo-plugin-recommendation.mdaccording to the file path_post/web/blog-framework/nodejs-hexo/plugin/hexo-plugin-recommendation.md.Does this PR introduce a breaking change?