diff --git a/config/_default/params.toml b/config/_default/params.toml index 9b1bd85..3b88444 100644 --- a/config/_default/params.toml +++ b/config/_default/params.toml @@ -66,11 +66,12 @@ alertDismissable = true alertText = "Introducing the Doks child theme, several DX + UX updates, and more! Check out Doks v0.2" # 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 diff --git a/layouts/partials/main/edit-page.html b/layouts/partials/main/edit-page.html index 30c0dba..5f5d762 100644 --- a/layouts/partials/main/edit-page.html +++ b/layouts/partials/main/edit-page.html @@ -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 "/" }}