Skip to content

Commit

Permalink
Merge pull request #496 from OCram85/editGitea
Browse files Browse the repository at this point in the history
✨Adds additional option for 'edit this page' feature
  • Loading branch information
h-enk authored Oct 8, 2021
2 parents 0cf93c9 + 63bed87 commit b1227d7
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 2 deletions.
3 changes: 3 additions & 0 deletions config/_default/params.toml
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,9 @@ alertDismissable = true
alertText = "Introducing the Doks child theme, several DX + UX updates, and more! <a class=\"alert-link stretched-link\" href=\"https://getdoks.org/blog/doks-v0.2/\">Check out Doks v0.2</a>"

# Edit Page
# repoHost [Github | Gitea | GitLab] is used for building the edit link based on git hoster
repoHost = "GitHub"
#repoHost = "Gitea"
docsRepo = "https://github.com/h-enk/doks"
docsRepoBranch = "master"
editPage = false
Expand Down
15 changes: 13 additions & 2 deletions layouts/partials/main/edit-page.html
Original file line number Diff line number Diff line change
@@ -1,5 +1,16 @@
{{ $filePath := replace .File.Path "\\" "/" }}
{{ $contentPath := print .Site.Params.docsRepo "/blob/" .Site.Params.docsRepoBranch "/content/" }}
{{ $editPath := "null" }}

{{ if (eq .Site.Params.repoHost "GitHub") }}
{{ $editPath = "/blob/" }}
{{ else if (eq .Site.Params.repoHost "Gitea") }}
{{ $editPath = "/_edit/" }}
{{ else if (eq .Site.Params.repoHost "GitLab") }}
{{ $editPath = "/-/blob/" }}
{{ end }}

{{ $contentPath := print .Site.Params.docsRepo $editPath .Site.Params.docsRepoBranch "/content/" }}

{{ $url := print $contentPath $filePath }}

{{ if .Site.Params.options.multilingualMode }}
Expand All @@ -11,6 +22,6 @@
<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="feather feather-edit-2">
<path d="M17 3a2.828 2.828 0 1 1 4 4L7.5 20.5 2 22l1.5-5.5L17 3z"></path>
</svg>
Edit this page on GitHub
Edit this page on {{ .Site.Params.repoHost }}
</a>
</p>

0 comments on commit b1227d7

Please sign in to comment.