From eecd6724db5a4460967411460751e4e8495e239f Mon Sep 17 00:00:00 2001 From: Patrice Chalin Date: Fri, 29 Oct 2021 10:54:43 -0400 Subject: [PATCH] Repo links: support file renames (#870) --- layouts/partials/page-meta-links.html | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/layouts/partials/page-meta-links.html b/layouts/partials/page-meta-links.html index 6100d6438..c07bd989a 100644 --- a/layouts/partials/page-meta-links.html +++ b/layouts/partials/page-meta-links.html @@ -15,7 +15,18 @@ {{ else if $gh_subdir }} {{ $gh_repo_path = printf "%s/%s/content/%s" $gh_branch $gh_subdir $pathFormatted }} {{ end }} -{{ $gh_repo_path = replace $gh_repo_path ($.Param "path_base_for_github_subdir") "" -}} + +{{ $ghs_base := $.Param "path_base_for_github_subdir" -}} +{{ $ghs_rename := "" -}} +{{ if reflect.IsMap $ghs_base -}} + {{ $ghs_rename = $ghs_base.to -}} + {{ $ghs_base = $ghs_base.from -}} +{{ end -}} + +{{ with $ghs_base -}} + {{ $gh_repo_path = replaceRE . $ghs_rename $gh_repo_path -}} +{{ end -}} + {{ $editURL := printf "%s/edit/%s" $gh_repo $gh_repo_path }} {{ $createURL := printf "%s/edit/%s" $gh_repo $gh_repo_path }} {{ $issuesURL := printf "%s/issues/new?title=%s" $gh_repo (htmlEscape $.Title )}}