mirror of
https://github.com/gohugoio/hugo.git
synced 2025-08-17 21:01:26 +02:00
Fix RSS with baseURL with sub dir when render hooks is enabled
Fixes #13332
This commit is contained in:
@@ -96,3 +96,51 @@ Figure:
|
||||
|
||||
b.AssertFileContent("public/index.xml", "img src="http://example.com/images/sunset.jpg")
|
||||
}
|
||||
|
||||
// Issue 13332.
|
||||
func TestRSSCanonifyURLsSubDir(t *testing.T) {
|
||||
t.Parallel()
|
||||
|
||||
files := `
|
||||
-- hugo.toml --
|
||||
baseURL = 'https://example.org/subdir'
|
||||
disableKinds = ['section','sitemap','taxonomy','term']
|
||||
[markup.goldmark.renderHooks.image]
|
||||
enableDefault = true
|
||||
[markup.goldmark.renderHooks.link]
|
||||
enableDefault = true
|
||||
-- layouts/_default/_markup/render-image.html --
|
||||
{{- $u := urls.Parse .Destination -}}
|
||||
{{- $src := $u.String | relURL -}}
|
||||
<img srcset="{{ $src }}" src="{{ $src }} 2x">
|
||||
<img src="{{ $src }}">
|
||||
{{- /**/ -}}
|
||||
-- layouts/_default/home.html --
|
||||
{{ .Content }}|
|
||||
-- layouts/_default/single.html --
|
||||
{{ .Content }}|
|
||||
-- layouts/_default/rss.xml --
|
||||
{{ with site.GetPage "/s1/p2" }}
|
||||
{{ .Content | transform.XMLEscape | safeHTML }}
|
||||
{{ end }}
|
||||
-- content/s1/p1.md --
|
||||
---
|
||||
title: p1
|
||||
---
|
||||
-- content/s1/p2/index.md --
|
||||
---
|
||||
title: p2
|
||||
---
|
||||

|
||||
|
||||
[p1](/s1/p1)
|
||||
-- content/s1/p2/a.jpg --
|
||||
`
|
||||
|
||||
b := Test(t, files)
|
||||
|
||||
b.AssertFileContent("public/index.xml", "https://example.org/subdir/s1/p1/")
|
||||
b.AssertFileContent("public/index.xml",
|
||||
"img src="https://example.org/subdir/a.jpg",
|
||||
"img srcset="https://example.org/subdir/a.jpg" src="https://example.org/subdir/a.jpg 2x")
|
||||
}
|
||||
|
Reference in New Issue
Block a user