From c265522cdb3750519fd2d165d328b0ef17597971 Mon Sep 17 00:00:00 2001 From: The Anh Nguyen Date: Wed, 23 Oct 2024 16:10:29 +0700 Subject: [PATCH] fix(docs): "Edit this page" URLs to correctly point to GitHub repository structure (#5289) * fix edit post link Signed-off-by: The Anh Nguyen * add condition to check gh_subdir & language Signed-off-by: The Anh Nguyen * remove _index.md condition Signed-off-by: The Anh Nguyen --------- Signed-off-by: The Anh Nguyen --- docs/layouts/partials/page-meta-links.html | 21 +++++++++++++-------- 1 file changed, 13 insertions(+), 8 deletions(-) diff --git a/docs/layouts/partials/page-meta-links.html b/docs/layouts/partials/page-meta-links.html index 0b82e9ba12..be9ed7974c 100644 --- a/docs/layouts/partials/page-meta-links.html +++ b/docs/layouts/partials/page-meta-links.html @@ -1,19 +1,24 @@ {{ if .Path }} -{{ $pathFormatted := replace .Path "\\" "/" }} {{ $gh_repo := ($.Param "github_repo") }} {{ $gh_subdir := ($.Param "github_subdir") }} {{ $gh_project_repo := ($.Param "github_project_repo") }} {{ $gh_branch := (default "master" ($.Param "github_branch")) }} {{ if $gh_repo }}
-{{ $editURL := printf "%s/edit/%s/content/%s" $gh_repo $gh_branch $pathFormatted }} -{{ if and ($gh_subdir) (.Site.Language.Lang) }} -{{ $editURL = printf "%s/edit/%s/%s/content/%s/%s" $gh_repo $gh_branch $gh_subdir ($.Site.Language.Lang) $pathFormatted }} -{{ else if .Site.Language.Lang }} -{{ $editURL = printf "%s/edit/%s/content/%s/%s" $gh_repo $gh_branch ($.Site.Language.Lang) $pathFormatted }} -{{ else if $gh_subdir }} -{{ $editURL = printf "%s/edit/%s/%s/content/%s" $gh_repo $gh_branch $gh_subdir $pathFormatted }} +{{ $editURL := printf "%s/edit/%s" $gh_repo $gh_branch }} +{{ if .File }} + {{ if .File.LogicalName }} + {{ if $gh_subdir }} + {{ $editURL = printf "%s/%s" $editURL $gh_subdir }} + {{ end }} + {{ $editURL = printf "%s/content" $editURL }} + {{ if .Site.Language.Lang }} + {{ $editURL = printf "%s/%s" $editURL .Site.Language.Lang }} + {{ end }} + {{ $editURL = printf "%s/%s" $editURL .File.Path }} + {{ end }} {{ end }} + {{ $issuesURL := printf "%s/issues/new?title=%s" $gh_repo (htmlEscape $.Title )}} {{ T "post_edit_this" }} {{ T "post_create_issue" }}