From 9cac14411dfaa705412dbdfec6de9ce56d89e38f Mon Sep 17 00:00:00 2001
From: weilining <18277278902@163.com>
Date: Mon, 11 Jan 2021 03:33:52 +0800
Subject: [PATCH 1/5] feat: Post edit Easily browse and edit blog source code
online
---
_config.yml | 7 +++++++
layout/includes/header/index.pug | 3 +++
layout/includes/header/post-info.pug | 5 ++++-
scripts/helpers/page.js | 6 ++++++
source/css/_layout/head.styl | 6 ++++++
5 files changed, 26 insertions(+), 1 deletion(-)
diff --git a/_config.yml b/_config.yml
index c8d391a..611f8fb 100644
--- a/_config.yml
+++ b/_config.yml
@@ -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:
diff --git a/layout/includes/header/index.pug b/layout/includes/header/index.pug
index 4efb3f9..02fa816 100644
--- a/layout/includes/header/index.pug
+++ b/layout/includes/header/index.pug
@@ -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
diff --git a/layout/includes/header/post-info.pug b/layout/includes/header/post-info.pug
index 9639512..66cde0e 100644
--- a/layout/includes/header/post-info.pug
+++ b/layout/includes/header/post-info.pug
@@ -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)
diff --git a/scripts/helpers/page.js b/scripts/helpers/page.js
index fd44158..d9274fb 100644
--- a/scripts/helpers/page.js
+++ b/scripts/helpers/page.js
@@ -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
+})
\ No newline at end of file
diff --git a/source/css/_layout/head.styl b/source/css/_layout/head.styl
index b081f93..3108759 100644
--- a/source/css/_layout/head.styl
+++ b/source/css/_layout/head.styl
@@ -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
From 0d4dce7fa6fdc287e121e72f77b4b36ba13d19bb Mon Sep 17 00:00:00 2001
From: weilining <18277278902@163.com>
Date: Wed, 13 Jan 2021 02:13:52 +0800
Subject: [PATCH 2/5] add i18n && padding-left: 0.3rem && annotation
---
_config.yml | 22 ++++++++++++----------
languages/default.yml | 3 ++-
languages/en.yml | 3 ++-
languages/zh-CN.yml | 7 ++++---
languages/zh-TW.yml | 7 ++++---
layout/includes/header/index.pug | 2 +-
layout/includes/header/post-info.pug | 2 +-
source/css/_layout/head.styl | 5 ++++-
8 files changed, 30 insertions(+), 21 deletions(-)
diff --git a/_config.yml b/_config.yml
index 611f8fb..4a22c9b 100644
--- a/_config.yml
+++ b/_config.yml
@@ -136,7 +136,7 @@ error_img:
# A simple 404 page
error_404:
enable: false
- subtitle: 'Page Not Found'
+ subtitle: "Page Not Found"
background: https://i.loli.net/2020/05/19/aKOcLiyPl2JQdFD.png
post_meta:
@@ -194,13 +194,15 @@ 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
+ # Link for view source
+ # url: https://github.com/user-name/repo-name/tree/branch-name/subdirectory-name/
+ # Link for fork & edit
+ # url: https://github.com/user-name/repo-name/edit/branch-name/subdirectory-name/
# Related Articles
related_post:
@@ -542,7 +544,7 @@ canvas_fluttering_ribbon:
# https://github.com/hustcc/canvas-nest.js
canvas_nest:
enable: false
- color: '0,0,255' #color of lines, default: '0,0,0'; RGB values: (R,G,B).(note: use ',' to separate.)
+ color: "0,0,255" #color of lines, default: '0,0,0'; RGB values: (R,G,B).(note: use ',' to separate.)
opacity: 0.7 # the opacity of line (0~1), default: 0.5.
zIndex: -1 # z-index property of the background, default: -1.
count: 99 # the number of lines, default: 99.
@@ -587,7 +589,7 @@ beautify:
enable: false
field: post # site/post
title-prefix-icon: '\f0c1'
- title-prefix-icon-color: '#F47466'
+ title-prefix-icon-color: "#F47466"
# Global font settings
# Don't modify the following settings unless you know how they work (非必要不要修改)
@@ -729,9 +731,9 @@ translate:
# Time delay
translateDelay: 0
# The text of the button when the language is Simplified Chinese
- msgToTraditionalChinese: '繁'
+ msgToTraditionalChinese: "繁"
# The text of the button when the language is Traditional Chinese
- msgToSimplifiedChinese: '簡'
+ msgToSimplifiedChinese: "簡"
# Read Mode (閲讀模式)
readmode: true
@@ -814,8 +816,8 @@ aplayerInject:
snackbar:
enable: false
position: bottom-left
- bg_light: '#49b1f5' # The background color of Toast Notification in light mode
- bg_dark: '#121212' # The background color of Toast Notification in dark mode
+ bg_light: "#49b1f5" # The background color of Toast Notification in light mode
+ bg_dark: "#121212" # The background color of Toast Notification in dark mode
# https://instant.page/
# prefetch (預加載)
diff --git a/languages/default.yml b/languages/default.yml
index 0983604..85b75c6 100644
--- a/languages/default.yml
+++ b/languages/default.yml
@@ -30,12 +30,13 @@ post:
copyright_notice: Copyright Notice
copyright_content: 'All articles in this blog are licensed under %s unless stating additionally.'
recommend: Related Articles
+ edited: Edited on
search: Search
algolia_search:
input_placeholder: Search for Posts
hits_empty: "We didn't find any results for the search: ${query}."
- hits_stats: '${hits} results found in ${time} ms'
+ hits_stats: "${hits} results found in ${time} ms"
local_search:
label: Local search
diff --git a/languages/en.yml b/languages/en.yml
index ae08d27..bf7f9dc 100644
--- a/languages/en.yml
+++ b/languages/en.yml
@@ -30,12 +30,13 @@ post:
copyright_notice: Copyright Notice
copyright_content: 'All articles in this blog are licensed under %s unless stating additionally.'
recommend: Related Articles
+ edited: Edited on
search: Search
algolia_search:
input_placeholder: Search for Posts
hits_empty: "We didn't find any results for the search: ${query}."
- hits_stats: '${hits} results found in ${time} ms'
+ hits_stats: "${hits} results found in ${time} ms"
local_search:
label: Local search
diff --git a/languages/zh-CN.yml b/languages/zh-CN.yml
index 753fc14..87ee0c5 100644
--- a/languages/zh-CN.yml
+++ b/languages/zh-CN.yml
@@ -31,17 +31,18 @@ post:
copyright_content: '本博客所有文章除特别声明外,均采用
%s 许可协议。转载请注明来自 %s!'
recommend: 相关推荐
+ edit: 编辑
search: 搜索
algolia_search:
input_placeholder: 搜索文章
- hits_empty: '找不到您查询的内容:${query}'
- hits_stats: '找到 ${hits} 条结果,用时 ${time} 毫秒'
+ hits_empty: "找不到您查询的内容:${query}"
+ hits_stats: "找到 ${hits} 条结果,用时 ${time} 毫秒"
local_search:
label: 本地搜索
input_placeholder: 搜索文章
- hits_empty: '找不到您查询的内容:${query}'
+ hits_empty: "找不到您查询的内容:${query}"
pagination:
prev: 上一篇
diff --git a/languages/zh-TW.yml b/languages/zh-TW.yml
index 21c4cda..e9373a6 100644
--- a/languages/zh-TW.yml
+++ b/languages/zh-TW.yml
@@ -31,17 +31,18 @@ post:
copyright_content: '本部落格所有文章除特別聲明外,均採用
%s 許可協議。轉載請註明來自 %s!'
recommend: 相關推薦
+ edit: 編輯
search: 搜尋
algolia_search:
input_placeholder: 搜尋文章
- hits_empty: '找不到您查詢的內容:${query}'
- hits_stats: '找到 ${hits} 條結果,用時 ${time} 毫秒'
+ hits_empty: "找不到您查詢的內容:${query}"
+ hits_stats: "找到 ${hits} 條結果,用時 ${time} 毫秒"
local_search:
label: 本地搜尋
input_placeholder: 搜尋文章
- hits_empty: '找不到您查詢的內容:${query}'
+ hits_empty: "找不到您查詢的內容:${query}"
pagination:
prev: 上一篇
diff --git a/layout/includes/header/index.pug b/layout/includes/header/index.pug
index 02fa816..8e4ccf3 100644
--- a/layout/includes/header/index.pug
+++ b/layout/includes/header/index.pug
@@ -49,5 +49,5 @@ header#page-header(class=isHomeClass style=bg_img)
#page-site-info
h1#site-title=site_title
if theme.post_edit.enable
- a.post-edit-link(href=post_edit(page.source) title="编辑")
+ a.post-edit-link(href=post_edit(page.source) title=_p('post.edit'))
i.fa.fa-pen-nib
diff --git a/layout/includes/header/post-info.pug b/layout/includes/header/post-info.pug
index 66cde0e..96ca6be 100644
--- a/layout/includes/header/post-info.pug
+++ b/layout/includes/header/post-info.pug
@@ -1,7 +1,7 @@
#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="编辑")
+ a.post-edit-link(href=post_edit(page.source) title=_p('post.edit'))
i.fa.fa-pen-nib
#post-meta
diff --git a/source/css/_layout/head.styl b/source/css/_layout/head.styl
index 3108759..1c737de 100644
--- a/source/css/_layout/head.styl
+++ b/source/css/_layout/head.styl
@@ -84,6 +84,9 @@
+maxWidth768()
top: 7rem
+ .post-edit-link
+ padding-left: 0.3rem
+
// post
&.post-bg
height: 20rem
@@ -143,7 +146,7 @@
font-size: 1.72em
.post-edit-link
- float: inline-end
+ padding-left: 0.3rem
#post-meta
color: var(--light-grey)
From 71dcb128bd44f32f0d44801d8f3f5321dfcd610c Mon Sep 17 00:00:00 2001
From: weilining <18277278902@163.com>
Date: Wed, 13 Jan 2021 02:21:12 +0800
Subject: [PATCH 3/5] recover code
---
_config.yml | 16 ++++++++--------
languages/default.yml | 2 +-
languages/en.yml | 2 +-
languages/zh-CN.yml | 6 +++---
languages/zh-TW.yml | 6 +++---
5 files changed, 16 insertions(+), 16 deletions(-)
diff --git a/_config.yml b/_config.yml
index 4a22c9b..b97c9f2 100644
--- a/_config.yml
+++ b/_config.yml
@@ -136,7 +136,7 @@ error_img:
# A simple 404 page
error_404:
enable: false
- subtitle: "Page Not Found"
+ subtitle: 'Page Not Found'
background: https://i.loli.net/2020/05/19/aKOcLiyPl2JQdFD.png
post_meta:
@@ -194,7 +194,7 @@ reward:
# - img: /img/alipay.jpg
# link:
# text: alipay
-
+
# Post edit
# Easily browse and edit blog source code online.
post_edit:
@@ -544,7 +544,7 @@ canvas_fluttering_ribbon:
# https://github.com/hustcc/canvas-nest.js
canvas_nest:
enable: false
- color: "0,0,255" #color of lines, default: '0,0,0'; RGB values: (R,G,B).(note: use ',' to separate.)
+ color: '0,0,255' #color of lines, default: '0,0,0'; RGB values: (R,G,B).(note: use ',' to separate.)
opacity: 0.7 # the opacity of line (0~1), default: 0.5.
zIndex: -1 # z-index property of the background, default: -1.
count: 99 # the number of lines, default: 99.
@@ -589,7 +589,7 @@ beautify:
enable: false
field: post # site/post
title-prefix-icon: '\f0c1'
- title-prefix-icon-color: "#F47466"
+ title-prefix-icon-color: '#F47466'
# Global font settings
# Don't modify the following settings unless you know how they work (非必要不要修改)
@@ -731,9 +731,9 @@ translate:
# Time delay
translateDelay: 0
# The text of the button when the language is Simplified Chinese
- msgToTraditionalChinese: "繁"
+ msgToTraditionalChinese: '繁'
# The text of the button when the language is Traditional Chinese
- msgToSimplifiedChinese: "簡"
+ msgToSimplifiedChinese: '簡'
# Read Mode (閲讀模式)
readmode: true
@@ -816,8 +816,8 @@ aplayerInject:
snackbar:
enable: false
position: bottom-left
- bg_light: "#49b1f5" # The background color of Toast Notification in light mode
- bg_dark: "#121212" # The background color of Toast Notification in dark mode
+ bg_light: '#49b1f5' # The background color of Toast Notification in light mode
+ bg_dark: '#121212' # The background color of Toast Notification in dark mode
# https://instant.page/
# prefetch (預加載)
diff --git a/languages/default.yml b/languages/default.yml
index 85b75c6..cea7767 100644
--- a/languages/default.yml
+++ b/languages/default.yml
@@ -36,7 +36,7 @@ search: Search
algolia_search:
input_placeholder: Search for Posts
hits_empty: "We didn't find any results for the search: ${query}."
- hits_stats: "${hits} results found in ${time} ms"
+ hits_stats: '${hits} results found in ${time} ms'
local_search:
label: Local search
diff --git a/languages/en.yml b/languages/en.yml
index bf7f9dc..ad3f433 100644
--- a/languages/en.yml
+++ b/languages/en.yml
@@ -36,7 +36,7 @@ search: Search
algolia_search:
input_placeholder: Search for Posts
hits_empty: "We didn't find any results for the search: ${query}."
- hits_stats: "${hits} results found in ${time} ms"
+ hits_stats: '${hits} results found in ${time} ms'
local_search:
label: Local search
diff --git a/languages/zh-CN.yml b/languages/zh-CN.yml
index 87ee0c5..c8bcd9e 100644
--- a/languages/zh-CN.yml
+++ b/languages/zh-CN.yml
@@ -36,13 +36,13 @@ post:
search: 搜索
algolia_search:
input_placeholder: 搜索文章
- hits_empty: "找不到您查询的内容:${query}"
- hits_stats: "找到 ${hits} 条结果,用时 ${time} 毫秒"
+ hits_empty: '找不到您查询的内容:${query}'
+ hits_stats: '找到 ${hits} 条结果,用时 ${time} 毫秒'
local_search:
label: 本地搜索
input_placeholder: 搜索文章
- hits_empty: "找不到您查询的内容:${query}"
+ hits_empty: '找不到您查询的内容:${query}'
pagination:
prev: 上一篇
diff --git a/languages/zh-TW.yml b/languages/zh-TW.yml
index e9373a6..e08b424 100644
--- a/languages/zh-TW.yml
+++ b/languages/zh-TW.yml
@@ -36,13 +36,13 @@ post:
search: 搜尋
algolia_search:
input_placeholder: 搜尋文章
- hits_empty: "找不到您查詢的內容:${query}"
- hits_stats: "找到 ${hits} 條結果,用時 ${time} 毫秒"
+ hits_empty: '找不到您查詢的內容:${query}'
+ hits_stats: '找到 ${hits} 條結果,用時 ${time} 毫秒'
local_search:
label: 本地搜尋
input_placeholder: 搜尋文章
- hits_empty: "找不到您查詢的內容:${query}"
+ hits_empty: '找不到您查詢的內容:${query}'
pagination:
prev: 上一篇
From 2e7b65834f86cc7c150e85fd3e701680acfe28a3 Mon Sep 17 00:00:00 2001
From: weilining <18277278902@163.com>
Date: Wed, 13 Jan 2021 02:30:25 +0800
Subject: [PATCH 4/5] fix i18n
---
languages/en.yml | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/languages/en.yml b/languages/en.yml
index ad3f433..584f714 100644
--- a/languages/en.yml
+++ b/languages/en.yml
@@ -30,7 +30,7 @@ post:
copyright_notice: Copyright Notice
copyright_content: 'All articles in this blog are licensed under %s unless stating additionally.'
recommend: Related Articles
- edited: Edited on
+ edit: Edited on
search: Search
algolia_search:
From 8a56d00c2f8332eb10389fea9e5da5eafc6eebfb Mon Sep 17 00:00:00 2001
From: weilining <18277278902@163.com>
Date: Wed, 13 Jan 2021 02:44:20 +0800
Subject: [PATCH 5/5] Update default.yml
fix i18n
---
languages/default.yml | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/languages/default.yml b/languages/default.yml
index cea7767..5e42ca1 100644
--- a/languages/default.yml
+++ b/languages/default.yml
@@ -30,7 +30,7 @@ post:
copyright_notice: Copyright Notice
copyright_content: 'All articles in this blog are licensed under %s unless stating additionally.'
recommend: Related Articles
- edited: Edited on
+ edit: Edited on
search: Search
algolia_search: