From abfdb54c92a26dcfaf876d2e06c1059ec9254694 Mon Sep 17 00:00:00 2001 From: Syphdias Date: Tue, 23 Mar 2021 10:28:26 +0100 Subject: [PATCH] Add option to show link in meta data for editing posts (#278) Usage - in site config => Params: editPost: URL: "https://github.com//content" Text: "Suggest Changes" # edit text appendFilePath: true # to append file path to Edit link - in front-matter vars => --- editPost: URL: "https://github.com//content" Text: "Suggest Changes" # edit text appendFilePath: true # to append file path to Edit link --- - Front-matter vars overrides global ones --- i18n/de.yaml | 3 +++ layouts/_default/single.html | 1 + layouts/partials/edit_post.html | 6 ++++++ 3 files changed, 10 insertions(+) create mode 100644 layouts/partials/edit_post.html diff --git a/i18n/de.yaml b/i18n/de.yaml index 66412775..fcb53301 100644 --- a/i18n/de.yaml +++ b/i18n/de.yaml @@ -14,3 +14,6 @@ - id: translations translation: "Übersetzungen" + +- id: edit_post + translation: "Bearbeiten" diff --git a/layouts/_default/single.html b/layouts/_default/single.html index 28689422..117ce7b0 100644 --- a/layouts/_default/single.html +++ b/layouts/_default/single.html @@ -16,6 +16,7 @@ {{- end}} diff --git a/layouts/partials/edit_post.html b/layouts/partials/edit_post.html new file mode 100644 index 00000000..21a33eb5 --- /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 }}| {{- end -}} + + {{- .Params.editPost.Text | default (.Site.Params.editPost.Text | default (i18n "edit_post" | default "Edit") ) -}} + +{{- end }}