|
| 1 | +{{/* cSpell:ignore querify subdir */ -}} |
1 | 2 | {{ if .File -}}
|
2 |
| -{{ $pathFormatted := strings.TrimPrefix hugo.WorkingDir $.File.Filename -}} |
3 |
| -{{ $gh_repo := ($.Param "github_repo") -}} |
4 |
| -{{ $gh_url := ($.Param "github_url") -}} |
5 |
| -{{ $gh_subdir := ($.Param "github_subdir") -}} |
6 |
| -{{ $gh_project_repo := ($.Param "github_project_repo") -}} |
7 |
| -{{ $gh_branch := (default "main" ($.Param "github_branch")) -}} |
| 3 | +{{ $path := strings.TrimPrefix (add hugo.WorkingDir "/") $.File.Filename -}} |
| 4 | +{{ $gh_repo := $.Param "github_repo" -}} |
| 5 | +{{ $gh_url := $.Param "github_url" -}} |
| 6 | +{{ $gh_subdir := $.Param "github_subdir" | default "" -}} |
| 7 | +{{ $gh_project_repo := $.Param "github_project_repo" -}} |
| 8 | +{{ $gh_branch := $.Param "github_branch" | default "main" -}} |
8 | 9 | <div class="td-page-meta ms-2 pb-1 pt-2 mb-0">
|
9 | 10 | {{ if $gh_url -}}
|
10 |
| - {{ warnf "Warning: use of `github_url` is deprecated. For details see https://www.docsy.dev/docs/adding-content/repository-links/#github_url-optional" -}} |
| 11 | + {{ warnf "Warning: use of `github_url` is deprecated. For details, see https://www.docsy.dev/docs/adding-content/repository-links/#github_url-optional" -}} |
11 | 12 | <a href="{{ $gh_url }}" target="_blank"><i class="fa-solid fa-pen-to-square fa-fw"></i> {{ T "post_edit_this" }}</a>
|
12 | 13 | {{ else if $gh_repo -}}
|
13 |
| - {{ $gh_repo_path := printf "%s%s" $gh_branch $pathFormatted -}} |
14 |
| - {{ if $gh_subdir -}} |
15 |
| - {{ $gh_repo_path = printf "%s/%s%s" $gh_branch $gh_subdir $pathFormatted -}} |
16 |
| - {{ end -}} |
17 | 14 |
|
18 |
| - {{/* Adjust $gh_repo_path based on path_base_for_github_subdir */ -}} |
| 15 | + {{/* Adjust $path based on path_base_for_github_subdir */ -}} |
19 | 16 | {{ $ghs_base := $.Param "path_base_for_github_subdir" -}}
|
20 | 17 | {{ $ghs_rename := "" -}}
|
21 | 18 | {{ if reflect.IsMap $ghs_base -}}
|
22 | 19 | {{ $ghs_rename = $ghs_base.to -}}
|
23 | 20 | {{ $ghs_base = $ghs_base.from -}}
|
24 | 21 | {{ end -}}
|
25 | 22 | {{ with $ghs_base -}}
|
26 |
| - {{ $gh_repo_path = replaceRE . $ghs_rename $gh_repo_path -}} |
| 23 | + {{ $path = replaceRE . $ghs_rename $path -}} |
27 | 24 | {{ end -}}
|
28 | 25 |
|
| 26 | + {{ $gh_repo_path := printf "%s/%s/%s" $gh_branch $gh_subdir $path -}} |
| 27 | + {{ $gh_repo_path = replaceRE "//+" "/" $gh_repo_path -}} |
| 28 | + |
29 | 29 | {{ $viewURL := printf "%s/tree/%s" $gh_repo $gh_repo_path -}}
|
30 | 30 | {{ $editURL := printf "%s/edit/%s" $gh_repo $gh_repo_path -}}
|
31 | 31 | {{ $issuesURL := printf "%s/issues/new?title=%s" $gh_repo (safeURL $.Title ) -}}
|
|
0 commit comments