mirror of
https://github.com/adityatelange/hugo-PaperMod.git
synced 2026-05-21 11:05:49 +00:00
refactor(edit_post): improve edit post URL handling and readability
This commit is contained in:
@@ -1,10 +1,20 @@
|
|||||||
{{- if and (or .Params.editPost.URL site.Params.editPost.URL) (not (.Param "editPost.disabled")) -}}
|
{{- if and (.Param "editPost.URL") (not (.Param "editPost.disabled")) -}}
|
||||||
{{- $fileUrlPath := path.Join .File.Path }}
|
{{- if or (.Param "author") (.Param "ShowReadingTime") (not .Date.IsZero) .IsTranslated }}
|
||||||
|
{{- printf " | " | safeHTML -}}
|
||||||
|
{{- end -}}
|
||||||
|
|
||||||
{{- if or .Params.author site.Params.author (.Param "ShowReadingTime") (not .Date.IsZero) .IsTranslated }} | {{- end -}}
|
{{- $editURL := .Param "editPost.URL" }}
|
||||||
<span>
|
{{- $appendFilePath := .Param "editPost.appendFilePath" | default false }}
|
||||||
<a href="{{ .Params.editPost.URL | default site.Params.editPost.URL }}{{ if .Params.editPost.appendFilePath | default ( site.Params.editPost.appendFilePath | default false ) }}/{{ $fileUrlPath }}{{ end }}" rel="noopener noreferrer edit" target="_blank">
|
{{- $editText := .Param "editPost.Text" | default (i18n "edit_post" ) -}}
|
||||||
{{- .Params.editPost.Text | default (site.Params.editPost.Text | default (i18n "edit_post" | default "Edit")) -}}
|
|
||||||
</a>
|
{{- if $appendFilePath -}}
|
||||||
</span>
|
{{- $fileUrlPath := path.Join .File.Path }}
|
||||||
|
{{- $editURL = printf "%s/%s" $editURL $fileUrlPath -}}
|
||||||
|
{{- end -}}
|
||||||
|
|
||||||
|
<span>
|
||||||
|
<a href="{{ $editURL }}" rel="noopener noreferrer edit" target="_blank">
|
||||||
|
{{- $editText -}}
|
||||||
|
</a>
|
||||||
|
</span>
|
||||||
{{- end }}
|
{{- end }}
|
||||||
|
|||||||
Reference in New Issue
Block a user