Merge pull request #618 from james-d-elliott/feat-docs-repo-subpath
feat: edit link docs repo subpath
This commit is contained in:
commit
79ad59f311
|
@ -66,11 +66,12 @@ 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 | Gitea | GitLab | Bitbucket | BitbucketServer ] is used for building the edit link based on git hoster
|
||||
repoHost = "GitHub"
|
||||
#repoHost = "Gitea"
|
||||
docsRepo = "https://github.com/h-enk/doks"
|
||||
docsRepoBranch = "master"
|
||||
docsRepoSubPath = ""
|
||||
editPage = false
|
||||
lastMod = false
|
||||
|
||||
|
|
|
@ -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 }}">
|
||||
|
|
Loading…
Reference in New Issue