♻️ Refactor: change the post edit url splicing rules

This commit is contained in:
Cell
2022-07-24 17:26:24 +08:00
parent 23f13f092a
commit b731ebfacb
4 changed files with 14 additions and 6 deletions
+1
View File
@@ -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
+4 -2
View File
@@ -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
+1 -1
Submodule docs updated: afecae955a...f7b304f8c3
+8 -3
View File
@@ -1,4 +1,5 @@
{{- $params := .Scratch.Get "params" -}}
{{- $gitRepo := (strings.TrimSuffix "/" .Site.Params.gitRepo) -}}
<div class="post-footer" id="post-footer">
<div class="post-info">
@@ -7,9 +8,9 @@
<span title={{ "2006-01-02 15:04:05" | .Lastmod.Format }}>
{{- with .Site.Params.dateformat | default "2006-01-02" | .Lastmod.Format -}}
{{- dict "Date" . | T "updatedOnDate" -}}
{{- if $.Site.Params.gitRepo -}}
{{- if $gitRepo -}}
{{- with $.GitInfo -}}
&nbsp;<a class="git-hash" href="{{ printf `%v/commit/%v` $.Site.Params.gitRepo .Hash }}" rel="external nofollow noopener noreferrer" target="_blank" title="commit by {{ .AuthorName }}({{ .AuthorEmail }}) {{ .Hash }}: {{ .Subject }}">
&nbsp;<a class="git-hash" href="{{ printf `%v/commit/%v` $gitRepo .Hash }}" rel="external nofollow noopener noreferrer" target="_blank" title="commit by {{ .AuthorName }}({{ .AuthorEmail }}) {{ .Hash }}: {{ .Subject }}">
<i class="fa-solid fa-hashtag fa-fw"></i>{{- .AbbreviatedHash -}}
</a>
{{- end -}}
@@ -38,7 +39,11 @@
{{- with $params.edit -}}
{{- if .Enable -}}
<span>
{{- $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 -}}
</span>
{{- end -}}