Merge pull request #618 from james-d-elliott/feat-docs-repo-subpath

feat: edit link docs repo subpath
This commit is contained in:
Henk Verlinde
2022-02-01 13:44:10 +01:00
committed by GitHub
2 changed files with 25 additions and 8 deletions

View File

@ -1,16 +1,32 @@
{{ $filePath := replace .File.Path "\\" "/" }}
{{ $editPath := "null" }}
{{ $parts := slice .Site.Params.docsRepo }}
{{ if (eq .Site.Params.repoHost "GitHub") }}
{{ $editPath = "/blob/" }}
{{ $parts = $parts | append "blob" .Site.Params.docsRepoBranch }}
{{ else if (eq .Site.Params.repoHost "Gitea") }}
{{ $editPath = "/_edit/" }}
{{ $parts = $parts | append "_edit" .Site.Params.docsRepoBranch }}
{{ else if (eq .Site.Params.repoHost "GitLab") }}
{{ $editPath = "/-/blob/" }}
{{ $parts = $parts | append "-/blob" .Site.Params.docsRepoBranch }}
{{ else if (eq .Site.Params.repoHost "Bitbucket") }}
{{ $parts = $parts | append "src" .Site.Params.docsRepoBranch }}
{{ else if (eq .Site.Params.repoHost "BitbucketServer") }}
{{ $parts = $parts | append "browse" .Site.Params.docsRepoBranch }}
{{ end }}
{{ $contentPath := print .Site.Params.docsRepo $editPath .Site.Params.docsRepoBranch "/content/" }}
{{ $url := print $contentPath .Lang "/" $filePath }}
{{ if isset .Site.Params "docsreposubpath" }}
{{ if not (eq .Site.Params.docsRepoSubPath "") }}
{{ $parts = $parts | append .Site.Params.docsRepoSubPath }}
{{ end }}
{{ end }}
{{ $filePath := replace .File.Path "\\" "/" }}
{{ if .Site.Params.options.multilingualMode }}
{{ $parts = $parts | append "content" .Lang $filePath }}
{{ else }}
{{ $parts = $parts | append "content" $filePath }}
{{ end }}
{{ $url := delimit $parts "/" }}
<div class="edit-page">
<a href="{{ $url }}">