feat: edit link docs repo subpath
Can be used if the folder with your content is in a subfolder so if your project wishes to contain code and docs in the same repo it's convenient to do so. Additionally includes some refactoring in the edit-page.html logic to make it easier to manage.
This commit is contained in:
parent
40a8705ab6
commit
1b6a1ca0cd
|
@ -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>"
|
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
|
# Edit Page
|
||||||
# repoHost [Github | Gitea | GitLab] is used for building the edit link based on git hoster
|
# repoHost [Github | Gitea | GitLab | Bitbucket ] is used for building the edit link based on git hoster
|
||||||
repoHost = "GitHub"
|
repoHost = "GitHub"
|
||||||
#repoHost = "Gitea"
|
#repoHost = "Gitea"
|
||||||
docsRepo = "https://github.com/h-enk/doks"
|
docsRepo = "https://github.com/h-enk/doks"
|
||||||
docsRepoBranch = "master"
|
docsRepoBranch = "master"
|
||||||
|
docsRepoSubPath = ""
|
||||||
editPage = false
|
editPage = false
|
||||||
lastMod = false
|
lastMod = false
|
||||||
|
|
||||||
|
|
|
@ -1,16 +1,29 @@
|
||||||
|
{{ $parts := slice .Site.Params.docsRepo }}
|
||||||
{{ $filePath := replace .File.Path "\\" "/" }}
|
{{ $filePath := replace .File.Path "\\" "/" }}
|
||||||
{{ $editPath := "null" }}
|
|
||||||
|
|
||||||
{{ if (eq .Site.Params.repoHost "GitHub") }}
|
{{ if (eq .Site.Params.repoHost "GitHub") }}
|
||||||
{{ $editPath = "/blob/" }}
|
{{ $parts = $parts | append "blob" .Site.Params.docsRepoBranch }}
|
||||||
{{ else if (eq .Site.Params.repoHost "Gitea") }}
|
{{ else if (eq .Site.Params.repoHost "Gitea") }}
|
||||||
{{ $editPath = "/_edit/" }}
|
{{ $parts = $parts | append "_edit" .Site.Params.docsRepoBranch }}
|
||||||
{{ else if (eq .Site.Params.repoHost "GitLab") }}
|
{{ 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 "browse" .Site.Params.docsRepoBranch }}
|
||||||
{{ end }}
|
{{ end }}
|
||||||
|
|
||||||
{{ $contentPath := print .Site.Params.docsRepo $editPath .Site.Params.docsRepoBranch "/content/" }}
|
{{ if isset .Site.Params "docsreposubpath" }}
|
||||||
{{ $url := print $contentPath .Lang "/" $filePath }}
|
{{ if not (eq .Site.Params.docsRepoSubPath "") }}
|
||||||
|
{{ $parts = $parts | append .Site.Params.docsRepoSubPath }}
|
||||||
|
{{ end }}
|
||||||
|
{{ end }}
|
||||||
|
|
||||||
|
{{ 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">
|
<div class="edit-page">
|
||||||
<a href="{{ $url }}">
|
<a href="{{ $url }}">
|
||||||
|
|
Loading…
Reference in New Issue