Skip to content

Commit

Permalink
Add option to show link in meta data for editing posts (#278)
Browse files Browse the repository at this point in the history
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
  • Loading branch information
Syphdias authored Mar 23, 2021
1 parent f3cac6c commit abfdb54
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 0 deletions.
3 changes: 3 additions & 0 deletions i18n/de.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -14,3 +14,6 @@

- id: translations
translation: "Übersetzungen"

- id: edit_post
translation: "Bearbeiten"
1 change: 1 addition & 0 deletions layouts/_default/single.html
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ <h1 class="post-title">
<div class="post-meta">
{{- partial "post_meta.html" . -}}
{{- partial "translation_list.html" . -}}
{{- partial "edit_post.html" . -}}
</div>
{{- end}}
</header>
Expand Down
6 changes: 6 additions & 0 deletions layouts/partials/edit_post.html
Original file line number Diff line number Diff line change
@@ -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 }}

0 comments on commit abfdb54

Please sign in to comment.