feat: Post edit Easily browse and edit blog source code online

This commit is contained in:
weilining
2021-01-11 03:33:52 +08:00
parent a1f86a1573
commit 9cac14411d
5 changed files with 26 additions and 1 deletions

View File

@@ -194,6 +194,13 @@ reward:
# - img: /img/alipay.jpg
# link:
# text: alipay
# Post edit
# Easily browse and edit blog source code online.
post_edit:
enable: false
url: https://github.com/user-name/repo-name/tree/branch-name/subdirectory-name/ # Link for view source
#url: https://github.com/user-name/repo-name/edit/branch-name/subdirectory-name/ # Link for fork & edit
# Related Articles
related_post:

View File

@@ -48,3 +48,6 @@ header#page-header(class=isHomeClass style=bg_img)
else
#page-site-info
h1#site-title=site_title
if theme.post_edit.enable
a.post-edit-link(href=post_edit(page.source) title="编辑")
i.fa.fa-pen-nib

View File

@@ -1,6 +1,9 @@
#post-info
h1.post-title= page.title || _p('no_title')
if theme.post_edit.enable
a.post-edit-link(href=post_edit(page.source) title="编辑")
i.fa.fa-pen-nib
#post-meta
.meta-firstline
if (theme.post_meta.post.date_type)

View File

@@ -70,3 +70,9 @@ hexo.extend.helper.register('injectHtml', function (data) {
}
return result
})
hexo.extend.helper.register('post_edit', function(src) {
const { post_edit } = this.theme;
if (!post_edit.enable) return '';
return post_edit.url + src
})

View File

@@ -141,6 +141,9 @@
+maxWidth768()
font-size: 1.72em
.post-edit-link
float: inline-end
#post-meta
color: var(--light-grey)
@@ -193,6 +196,9 @@
border-bottom: 1px solid var(--light-grey)
color: var(--text-highlight-color)
.post-edit-link
float: right
#post-meta,
#post-meta a
color: #78818a