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
This commit is contained in:
Syphdias 2021-03-23 10:28:26 +01:00 committed by GitHub
parent f3cac6c09e
commit abfdb54c92
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 10 additions and 0 deletions

View File

@ -14,3 +14,6 @@
- id: translations - id: translations
translation: "Übersetzungen" translation: "Übersetzungen"
- id: edit_post
translation: "Bearbeiten"

View File

@ -16,6 +16,7 @@
<div class="post-meta"> <div class="post-meta">
{{- partial "post_meta.html" . -}} {{- partial "post_meta.html" . -}}
{{- partial "translation_list.html" . -}} {{- partial "translation_list.html" . -}}
{{- partial "edit_post.html" . -}}
</div> </div>
{{- end}} {{- end}}
</header> </header>

View File

@ -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 }}