summaryrefslogtreecommitdiff
path: root/layouts
diff options
context:
space:
mode:
authorSyphdias <syphdias+git@gmail.com>2021-03-23 10:28:26 +0100
committerGitHub <noreply@github.com>2021-03-23 14:58:26 +0530
commitabfdb54c92a26dcfaf876d2e06c1059ec9254694 (patch)
tree82a3c9140c0a6fbf5b07e19df978321386d8838e /layouts
parentf3cac6c09e02d9ac2836906368608a4955c1ef42 (diff)
Add option to show link in meta data for editing posts (#278)
Usage - in site config => Params: editPost: URL: "https://github.com/<path_to_repo>/content" Text: "Suggest Changes" # edit text appendFilePath: true # to append file path to Edit link - in front-matter vars => --- editPost: URL: "https://github.com/<path_to_repo>/content" Text: "Suggest Changes" # edit text appendFilePath: true # to append file path to Edit link --- - Front-matter vars overrides global ones
Diffstat (limited to 'layouts')
-rw-r--r--layouts/_default/single.html1
-rw-r--r--layouts/partials/edit_post.html6
2 files changed, 7 insertions, 0 deletions
diff --git a/layouts/_default/single.html b/layouts/_default/single.html
index 2868942..117ce7b 100644
--- a/layouts/_default/single.html
+++ b/layouts/_default/single.html
@@ -16,6 +16,7 @@
<div class="post-meta">
{{- partial "post_meta.html" . -}}
{{- partial "translation_list.html" . -}}
+ {{- partial "edit_post.html" . -}}
</div>
{{- end}}
</header>
diff --git a/layouts/partials/edit_post.html b/layouts/partials/edit_post.html
new file mode 100644
index 0000000..21a33eb
--- /dev/null
+++ b/layouts/partials/edit_post.html
@@ -0,0 +1,6 @@
+{{- if or .Params.editPost.URL .Site.Params.editPost.URL -}}
+{{- if or .Params.author $.Site.Params.author (.Param "ShowReadingTime") (not .Date.IsZero) .IsTranslated }}|&nbsp;{{- end -}}
+<a href="{{ .Params.editPost.URL | default .Site.Params.editPost.URL }}{{ if .Params.editPost.appendFilePath | default ( .Site.Params.editPost.appendFilePath | default false ) }}/{{ .File.Path }}{{ end }}" rel="noopener noreferrer" target="_blank">
+ {{- .Params.editPost.Text | default (.Site.Params.editPost.Text | default (i18n "edit_post" | default "Edit") ) -}}
+</a>
+{{- end }}