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")) -}}
|
||||
{{- $fileUrlPath := path.Join .File.Path }}
|
||||
{{- if and (.Param "editPost.URL") (not (.Param "editPost.disabled")) -}}
|
||||
{{- if or (.Param "author") (.Param "ShowReadingTime") (not .Date.IsZero) .IsTranslated }}
|
||||
{{- printf " | " | safeHTML -}}
|
||||
{{- end -}}
|
||||
|
||||
{{- $editURL := .Param "editPost.URL" }}
|
||||
{{- $appendFilePath := .Param "editPost.appendFilePath" | default false }}
|
||||
{{- $editText := .Param "editPost.Text" | default (i18n "edit_post" ) -}}
|
||||
|
||||
{{- if $appendFilePath -}}
|
||||
{{- $fileUrlPath := path.Join .File.Path }}
|
||||
{{- $editURL = printf "%s/%s" $editURL $fileUrlPath -}}
|
||||
{{- end -}}
|
||||
|
||||
{{- if or .Params.author site.Params.author (.Param "ShowReadingTime") (not .Date.IsZero) .IsTranslated }} | {{- end -}}
|
||||
<span>
|
||||
<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">
|
||||
{{- .Params.editPost.Text | default (site.Params.editPost.Text | default (i18n "edit_post" | default "Edit")) -}}
|
||||
<a href="{{ $editURL }}" rel="noopener noreferrer edit" target="_blank">
|
||||
{{- $editText -}}
|
||||
</a>
|
||||
</span>
|
||||
{{- end }}
|
||||
|
||||
Reference in New Issue
Block a user