]> git.maquefel.me Git - brevno-suite/hugo/commitdiff
Fix recent regression .Resources.Get for resources with spaces in filename
authorBjørn Erik Pedersen <bjorn.erik.pedersen@gmail.com>
Tue, 30 Jan 2024 09:42:24 +0000 (10:42 +0100)
committerBjørn Erik Pedersen <bjorn.erik.pedersen@gmail.com>
Tue, 30 Jan 2024 19:12:03 +0000 (20:12 +0100)
Fixes #11944

hugolib/content_map_page.go
hugolib/content_map_test.go
resources/page/pagemeta/page_frontmatter.go

index 9fee740033007c3bd0e9d5a87f95b21162b28da9..9accd190ec48137c6483c22359eb1079a4f76c87 100644 (file)
@@ -1548,7 +1548,7 @@ func (sa *sitePagesAssembler) assembleResources() error {
                                                return false, nil
                                        }
 
-                                       relPathOriginal := rs.path.PathRel(ps.m.pathInfo)
+                                       relPathOriginal := rs.path.Unmormalized().PathRel(ps.m.pathInfo.Unmormalized())
                                        relPath := rs.path.BaseRel(ps.m.pathInfo)
 
                                        var targetBasePaths []string
index a41b2aae91699e09ef9a0350ca0cb2e75f4cca75..7843ad2858908f8fb61f8e5414197b8634053990 100644 (file)
@@ -280,3 +280,22 @@ P1: {{ $p1.Title }}|{{ $p1.Params.foo }}|{{ $p1.File.Filename }}|
                filepath.FromSlash("P1: P1 md|md|/content/p1.md|"),
        )
 }
+
+// Issue #11944
+func TestBundleResourcesGetWithSpacesInFilename(t *testing.T) {
+       files := `
+-- hugo.toml --
+baseURL = "https://example.com"
+disableKinds = ["taxonomy", "term"]
+-- content/bundle/index.md --
+-- content/bundle/data with Spaces.txt --
+Data.
+-- layouts/index.html --
+{{ $bundle := site.GetPage "bundle" }}
+{{ $r := $bundle.Resources.Get "data with Spaces.txt" }}
+R: {{ with $r }}{{ .Content }}{{ end }}|
+`
+       b := Test(t, files)
+
+       b.AssertFileContent("public/index.html", "R: Data.")
+}
index 17859d846cd4c52d4e00c05b7c4adfe0dca25dae..8abd3807fe4e9358c75ebde857d680736b357bec 100644 (file)
@@ -57,7 +57,7 @@ func (d Dates) IsAllDatesZero() bool {
 // Note that all the top level fields are reserved Hugo keywords.
 // Any custom configuration needs to be set in the Params map.
 type PageConfig struct {
-       Dates                   // Dates holds the fource core dates for this page.
+       Dates                   // Dates holds the four core dates for this page.
        Title          string   // The title of the page.
        LinkTitle      string   // The link title of the page.
        Type           string   // The content type of the page.
@@ -66,6 +66,7 @@ type PageConfig struct {
        Weight         int      // The weight of the page, used in sorting if set to a non-zero value.
        Kind           string   // The kind of page, e.g. "page", "section", "home" etc. This is usually derived from the content path.
        Path           string   // The canonical path to the page, e.g. /sect/mypage. Note: Leading slash, no trailing slash, no extensions or language identifiers.
+       URL            string   // The URL to the rendered page, e.g. /sect/mypage.html.
        Lang           string   // The language code for this page. This is usually derived from the module mount or filename.
        Slug           string   // The slug for this page.
        Description    string   // The description for this page.