From b731ebfacbeb6b5ac812f5dec49d6663d804100c Mon Sep 17 00:00:00 2001 From: Cell <1024@lruihao.cn> Date: Sun, 24 Jul 2022 17:26:24 +0800 Subject: [PATCH] :recycle: Refactor: change the post edit url splicing rules --- CHANGELOG.md | 1 + config.toml | 6 ++++-- docs | 2 +- layouts/partials/single/footer.html | 11 ++++++++--- 4 files changed, 14 insertions(+), 6 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 9d0c979e..0d5fbb82 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -22,6 +22,7 @@ All notable changes to this project will be documented in this file. - :bug: Fix: close comment system logic error when the article was expired - :bug: Style: fix typos for rel attribute value noreferrer (@yureiita[#157](https://github.com/Lruihao/FixIt/pull/157)) - :recycle: Refactor: migrate service-worker.js to js.build +- :recycle: Refactor: change the post edit url splicing rules - :mag: Feat(SEO): add options to make output `baidu_urls.txt` file ([#138](https://github.com/Lruihao/FixIt/issues/138)) - :truck: Perf: subdivide FixIt initialization - :art: Style: add theme colors variables and add common color styles diff --git a/config.toml b/config.toml index dd66bb4d..ec996d27 100644 --- a/config.toml +++ b/config.toml @@ -360,8 +360,10 @@ # FixIt 0.2.14 | NEW 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 = "" # Link for fork & edit + # FixIt 0.2.15 | CHANGED Link for fork & edit + # url = "/edit/branch-name/subdirectory-name" # base on `params.gitRepo` + # url = "https://github.com/user-name/repo-name/edit/branch-name/subdirectory-name" # full url + url = "" # FixIt 0.2.0 | NEW Mapbox GL JS config (https://docs.mapbox.com/mapbox-gl-js) [params.page.mapbox] # access token of Mapbox GL JS diff --git a/docs b/docs index afecae95..f7b304f8 160000 --- a/docs +++ b/docs @@ -1 +1 @@ -Subproject commit afecae955aefa8bc99faedbf9311265c6a9b9728 +Subproject commit f7b304f8c3060df30b6997c7e2c3bd667d628b23 diff --git a/layouts/partials/single/footer.html b/layouts/partials/single/footer.html index a5c595df..81787222 100644 --- a/layouts/partials/single/footer.html +++ b/layouts/partials/single/footer.html @@ -1,4 +1,5 @@ {{- $params := .Scratch.Get "params" -}} +{{- $gitRepo := (strings.TrimSuffix "/" .Site.Params.gitRepo) -}}
@@ -7,9 +8,9 @@ {{- with .Site.Params.dateformat | default "2006-01-02" | .Lastmod.Format -}} {{- dict "Date" . | T "updatedOnDate" -}} - {{- if $.Site.Params.gitRepo -}} + {{- if $gitRepo -}} {{- with $.GitInfo -}} -   +   {{- .AbbreviatedHash -}} {{- end -}} @@ -38,7 +39,11 @@ {{- with $params.edit -}} {{- if .Enable -}} - {{- $options := dict "Class" "link-to-edit" "Destination" (printf "%v/%v" (strings.TrimSuffix "/" .Url) $.File.Path) "Title" (T "editThisPage") "Content" (T "editThisPage") "externalIcon" false -}} + {{- $editUrl := printf "%v/%v" (strings.TrimSuffix "/" .Url) $.File.Path -}} + {{- if not (hasPrefix $editUrl "http") -}} + {{- $editUrl = printf "%v/%v" $gitRepo (strings.TrimPrefix "/" $editUrl) -}} + {{- end -}} + {{- $options := dict "Class" "link-to-edit" "Destination" $editUrl "Title" (T "editThisPage") "Content" (T "editThisPage") "externalIcon" false -}} {{- partial "plugin/link.html" $options -}} {{- end -}}