URI: 
       tpl/tplimpl: Resolve render hook destinations with leading ./ - hugo - [fork] hugo port for 9front
  HTML git clone git@git.drkhsh.at/hugo.git
   DIR Log
   DIR Files
   DIR Refs
   DIR Submodules
   DIR README
   DIR LICENSE
       ---
   DIR commit b893a09aa62c01a62e32b0effdb02e86b51d46d6
   DIR parent 6b006616e5423c0906f2bfc52e103261fdfb04ef
  HTML Author: Joe Mooring <joe.mooring@veriphor.com>
       Date:   Fri, 17 May 2024 15:41:18 -0700
       
       tpl/tplimpl: Resolve render hook destinations with leading ./
       
       Closes #12514
       
       Diffstat:
         M tpl/tplimpl/embedded/templates/_de… |       3 ++-
         M tpl/tplimpl/embedded/templates/_de… |       7 ++++---
         M tpl/tplimpl/render_hook_integratio… |      21 ++++++++++++++++-----
       
       3 files changed, 22 insertions(+), 9 deletions(-)
       ---
   DIR diff --git a/tpl/tplimpl/embedded/templates/_default/_markup/render-image.html b/tpl/tplimpl/embedded/templates/_default/_markup/render-image.html
       @@ -1,7 +1,8 @@
        {{- $u := urls.Parse .Destination -}}
        {{- $src := $u.String -}}
        {{- if not $u.IsAbs -}}
       -  {{- with or (.PageInner.Resources.Get $u.Path) (resources.Get $u.Path) -}}
       +  {{- $path := strings.TrimPrefix "./" $u.Path }}
       +  {{- with or (.PageInner.Resources.Get $path) (resources.Get $path) -}}
            {{- $src = .RelPermalink -}}
            {{- with $u.RawQuery -}}
              {{- $src = printf "%s?%s" $src . -}}
   DIR diff --git a/tpl/tplimpl/embedded/templates/_default/_markup/render-link.html b/tpl/tplimpl/embedded/templates/_default/_markup/render-link.html
       @@ -3,10 +3,11 @@
        {{- if strings.HasPrefix $u.String "#" }}
          {{- $href = printf "%s#%s" .PageInner.RelPermalink $u.Fragment }}
        {{- else if not $u.IsAbs -}}
       +  {{- $path := strings.TrimPrefix "./" $u.Path }}
          {{- with or
       -    ($.PageInner.GetPage $u.Path)
       -    ($.PageInner.Resources.Get $u.Path)
       -    (resources.Get $u.Path)
       +    ($.PageInner.GetPage $path)
       +    ($.PageInner.Resources.Get $path)
       +    (resources.Get $path)
          -}}
            {{- $href = .RelPermalink -}}
            {{- with $u.RawQuery -}}
   DIR diff --git a/tpl/tplimpl/render_hook_integration_test.go b/tpl/tplimpl/render_hook_integration_test.go
       @@ -51,7 +51,8 @@ title: s1/p1
        title: s1/p2
        ---
        [500](a.txt) // global resource
       -[600](b.txt) // page resource
       +[510](b.txt) // page resource
       +[520](./b.txt) // page resource
        -- content/s1/p2/b.txt --
        irrelevant
        -- content/s1/p3.md --
       @@ -125,12 +126,14 @@ title: s1/p3
        
                b.AssertFileContent("public/s1/p2/index.html",
                        `<a href="/a.txt">500</a>`,
       -                `<a href="/s1/p2/b.txt">600</a>`,
       +                `<a href="/s1/p2/b.txt">510</a>`,
       +                `<a href="/s1/p2/b.txt">520</a>`,
                )
        }
        
        // Issue 12203
        // Issue 12468
       +// Issue 12514
        func TestEmbeddedImageRenderHook(t *testing.T) {
                t.Parallel()
        
       @@ -145,7 +148,9 @@ block = false
        [markup.goldmark.renderHooks.image]
        enableDefault = true
        -- content/p1/index.md --
       -![alt](pixel.png?a=b&c=d#fragment)
       +![alt1](./pixel.png)
       +
       +![alt2](pixel.png?a=b&c=d#fragment)
        {.foo #bar}
        -- content/p1/pixel.png --
        iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAADUlEQVR42mNkYPhfDwAChwGA60e6kgAAAABJRU5ErkJggg==
       @@ -154,10 +159,16 @@ iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAADUlEQVR42mNkYPhfDwAChwGA60e6kgAA
        `
        
                b := hugolib.Test(t, files)
       -        b.AssertFileContent("public/p1/index.html", `<img alt="alt" src="/dir/p1/pixel.png?a=b&c=d#fragment">`)
       +        b.AssertFileContent("public/p1/index.html",
       +                `<img alt="alt1" src="/dir/p1/pixel.png">`,
       +                `<img alt="alt2" src="/dir/p1/pixel.png?a=b&c=d#fragment">`,
       +        )
        
                files = strings.Replace(files, "block = false", "block = true", -1)
        
                b = hugolib.Test(t, files)
       -        b.AssertFileContent("public/p1/index.html", `<img alt="alt" class="foo" id="bar" src="/dir/p1/pixel.png?a=b&c=d#fragment">`)
       +        b.AssertFileContent("public/p1/index.html",
       +                `<img alt="alt1" src="/dir/p1/pixel.png">`,
       +                `<img alt="alt2" class="foo" id="bar" src="/dir/p1/pixel.png?a=b&c=d#fragment">`,
       +        )
        }