Skip to content

Commit

Permalink
Fix resource name in resources.ByType
Browse files Browse the repository at this point in the history
Fixes #12190
  • Loading branch information
bep committed Mar 7, 2024
1 parent 4d5e173 commit a4b1747
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 4 deletions.
2 changes: 1 addition & 1 deletion hugolib/mount_filters_test.go
Expand Up @@ -112,6 +112,6 @@ Template: false
Resource1: /js/include.js:END
Resource2: :END
Resource3: :END
Resources: [/js/include.js]
Resources: [include.js]
`)
}
7 changes: 5 additions & 2 deletions resources/resource_factories/create/create.go
Expand Up @@ -128,13 +128,16 @@ func (c *Client) match(name, pattern string, matchFunc func(r resource.Resource)

handle := func(info hugofs.FileMetaInfo) (bool, error) {
meta := info.Meta()

r, err := c.rs.NewResource(resources.ResourceSourceDescriptor{
LazyPublish: true,
OpenReadSeekCloser: func() (hugio.ReadSeekCloser, error) {
return meta.Open()
},
GroupIdentity: meta.PathInfo,
TargetPath: meta.PathInfo.Unnormalized().Path(),
NameNormalized: meta.PathInfo.Name(),
NameOriginal: meta.PathInfo.Unnormalized().Name(),
GroupIdentity: meta.PathInfo,
TargetPath: meta.PathInfo.Unnormalized().Path(),
})
if err != nil {
return true, err
Expand Down
2 changes: 1 addition & 1 deletion tpl/resources/resources_integration_test.go
Expand Up @@ -155,6 +155,7 @@ I am a.txt
-- assets/b.txt --
I am b.txt
-- layouts/index.html --
Home.
{{ with resources.ByType "text" }}
{{ with .Get "a.txt" }}
{{ .Publish }}
Expand All @@ -167,7 +168,6 @@ I am b.txt

b := hugolib.Test(t, files)

b.AssertFileExists("public/index.html", true)
b.AssertFileExists("public/a.txt", true) // failing test
b.AssertFileExists("public/b.txt", true) // failing test
}

0 comments on commit a4b1747

Please sign in to comment.