From b92ef741bffb60872ccec59e50672dec7d6acf72 Mon Sep 17 00:00:00 2001
From: Cell <1024@lruihao.cn>
Date: Thu, 21 Apr 2022 11:06:08 +0800
Subject: [PATCH] :sparkles: Feat: add "Edit this page" button support (#103)
---
CHANGELOG.md | 3 ++-
assets/css/_partial/_single/_footer.scss | 8 +++++++-
exampleSite/config.toml | 6 ++++++
.../posts/theme-documentation-basics/index.en.md | 5 +++++
.../posts/theme-documentation-basics/index.zh-cn.md | 5 +++++
i18n/en.toml | 3 +++
i18n/zh-CN.toml | 3 +++
i18n/zh-TW.toml | 3 +++
layouts/partials/single/footer.html | 13 ++++++++++---
9 files changed, 44 insertions(+), 5 deletions(-)
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 7fe18567..4a8f35fb 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -15,9 +15,10 @@ All notable changes to this project will be documented in this file.
- Add download icon for downloadable links
- :sparkles: Feat: link shortcode add `external-icon` option ([#96](https://github.com/Lruihao/FixIt/issues/96))
- :sparkles: Feat: add GitHub Corners support ([#106](https://github.com/Lruihao/FixIt/issues/106))
+- :sparkles: Feat: add "Edit this page" button support ([#103](https://github.com/Lruihao/FixIt/issues/103))
- :bug: Fix: invalid front matter `comment: true` ([#108](https://github.com/Lruihao/FixIt/issues/108))
- :bug: Fix: ibruce and watermark option negative value error ([#114](https://github.com/Lruihao/FixIt/issues/114))
-- :sparkles: Style: add some common CSS styles Class ([#101](https://github.com/Lruihao/FixIt/issues/101))
+- :lipstick: Style: add some common CSS styles Class ([#101](https://github.com/Lruihao/FixIt/issues/101))
- :lipstick: Style: add the gap between and icon and text at blending typesetting (@ctj12461, @Lruihao[#118](https://github.com/Lruihao/FixIt/pull/118))
- :lipstick: Style: modify blockquote CSS
- :memo: Docs: revised theme documentations
diff --git a/assets/css/_partial/_single/_footer.scss b/assets/css/_partial/_single/_footer.scss
index 6c0be1ab..e98c8a79 100644
--- a/assets/css/_partial/_single/_footer.scss
+++ b/assets/css/_partial/_single/_footer.scss
@@ -37,9 +37,15 @@
.post-info-md {
font-size: 0.8rem;
- width: 8rem;
+ width: fit-content;
@include link(false, false);
+
+ >span:not(:first-child)::before {
+ content: '|';
+ margin-left: 0.25rem;
+ margin-right: 0.25rem;
+ }
}
.post-info-share {
diff --git a/exampleSite/config.toml b/exampleSite/config.toml
index a72c6d62..6fb908ec 100644
--- a/exampleSite/config.toml
+++ b/exampleSite/config.toml
@@ -714,6 +714,12 @@ enableEmoji = true
# the maximum number of lines of displayed code by default
# 默认展开显示的代码行数
maxShownLines = 10
+ # Post edit since v0.2.14
+ # 文章编辑 since v0.2.14
+ [params.page.edit]
+ enable = true
+ # url = "https://github.com/user-name/repo-name/edit/branch-name/subdirectory-name" # Link for fork & edit
+ url = "https://github.com/Lruihao/FixIt/edit/master/exampleSite/content" # Link for fork & edit
# KaTeX mathematical formulas config (KaTeX https://katex.org/)
# KaTeX 数学公式配置 (KaTeX https://katex.org/)
[params.page.math]
diff --git a/exampleSite/content/posts/theme-documentation-basics/index.en.md b/exampleSite/content/posts/theme-documentation-basics/index.en.md
index b1b71264..56a5c40e 100644
--- a/exampleSite/content/posts/theme-documentation-basics/index.en.md
+++ b/exampleSite/content/posts/theme-documentation-basics/index.en.md
@@ -495,6 +495,11 @@ Please open the code block below to view the complete sample configuration :(far
edit = true
# the maximum number of lines of displayed code by default
maxShownLines = 10
+ # {{< version 0.2.14 >}} Post edit
+ [params.page.edit]
+ enable = false
+ # url = "https://github.com/user-name/repo-name/edit/branch-name/subdirectory-name" # Link for fork & edit
+ url = "https://github.com/Lruihao/FixIt/edit/master/exampleSite/content" # Link for fork & edit
# {{< version 0.2.0 >}} {{< link "https://docs.mapbox.com/mapbox-gl-js" "Mapbox GL JS" >}} config (https://docs.mapbox.com/mapbox-gl-js)
[params.page.mapbox]
# access token of Mapbox GL JS
diff --git a/exampleSite/content/posts/theme-documentation-basics/index.zh-cn.md b/exampleSite/content/posts/theme-documentation-basics/index.zh-cn.md
index bf1f05c0..1a0b3bca 100644
--- a/exampleSite/content/posts/theme-documentation-basics/index.zh-cn.md
+++ b/exampleSite/content/posts/theme-documentation-basics/index.zh-cn.md
@@ -492,6 +492,11 @@ hugo
edit = true
# 默认展开显示的代码行数
maxShownLines = 10
+ # {{< version 0.2.14 >}} 文章编辑
+ [params.page.edit]
+ enable = false
+ # url = "https://github.com/user-name/repo-name/edit/branch-name/subdirectory-name" # Link for fork & edit
+ url = "https://github.com/Lruihao/FixIt/edit/master/exampleSite/content" # Link for fork & edit
# {{< version 0.2.0 changed >}} {{< link "https://katex.org/" KaTeX >}} 数学公式 (https://katex.org)
[params.page.math]
enable = true
diff --git a/i18n/en.toml b/i18n/en.toml
index 2c491fa9..578a1c56 100644
--- a/i18n/en.toml
+++ b/i18n/en.toml
@@ -153,6 +153,9 @@ other = "Updated on {{ .Date }}"
[readMarkdown]
other = "Read Markdown"
+[editThisPage]
+other = "Edit this page"
+
[back]
other = "Back"
diff --git a/i18n/zh-CN.toml b/i18n/zh-CN.toml
index b6e23975..90ab619a 100644
--- a/i18n/zh-CN.toml
+++ b/i18n/zh-CN.toml
@@ -158,6 +158,9 @@ other = "更新于 {{ .Date }}"
[readMarkdown]
other = "阅读原始文档"
+[editThisPage]
+other = "编辑此页"
+
[back]
other = "返回"
diff --git a/i18n/zh-TW.toml b/i18n/zh-TW.toml
index 99136196..7a588585 100644
--- a/i18n/zh-TW.toml
+++ b/i18n/zh-TW.toml
@@ -158,6 +158,9 @@ other = "更新於 {{ .Date }}"
[readMarkdown]
other = "閱讀原始文檔"
+[editThisPage]
+other = "編輯此頁"
+
[back]
other = "返回"
diff --git a/layouts/partials/single/footer.html b/layouts/partials/single/footer.html
index 8918212e..af38b3e9 100644
--- a/layouts/partials/single/footer.html
+++ b/layouts/partials/single/footer.html
@@ -30,9 +30,16 @@
{{- if $params.linktomarkdown -}}
{{- with .OutputFormats.Get "markdown" -}}
-
- {{- T "readMarkdown" -}}
-
+ {{- $options := dict "Class" "link-to-markdown" "Destination" .RelPermalink "Title" (T "readMarkdown") "Content" (T "readMarkdown") "externalIcon" false -}}
+ {{- partial "plugin/link.html" $options -}}
+
+ {{- end -}}
+ {{- end -}}
+ {{- with $params.edit -}}
+ {{- if .Enable -}}
+
+ {{- $options := dict "Class" "link-to-edit" "Destination" (printf "%v/%v" .Url $.File.Path) "Title" (T "editThisPage") "Content" (T "editThisPage") "externalIcon" false -}}
+ {{- partial "plugin/link.html" $options -}}
{{- end -}}
{{- end -}}