diff options
author | Bjørn Erik Pedersen <[email protected]> | 2019-09-12 19:53:31 +0200 |
---|---|---|
committer | Bjørn Erik Pedersen <[email protected]> | 2019-09-12 20:58:06 +0200 |
commit | c0d7573677e9726c14749ccd432dccb75e0d194d (patch) | |
tree | 7c77b664ea6a24947d6fceea6aefede8a6fc801e | |
parent | fcfa6f33bbebc128a3f9bc3162173bc3780c5f50 (diff) | |
download | hugo-c0d7573677e9726c14749ccd432dccb75e0d194d.tar.gz hugo-c0d7573677e9726c14749ccd432dccb75e0d194d.zip |
Fix cache keys for bundled resoures in transform.Unmarshal
Fixes #6327
-rw-r--r-- | hugolib/hugo_smoke_test.go | 30 | ||||
-rw-r--r-- | resources/resource.go | 2 | ||||
-rw-r--r-- | resources/resource_test.go | 2 |
3 files changed, 32 insertions, 2 deletions
diff --git a/hugolib/hugo_smoke_test.go b/hugolib/hugo_smoke_test.go index 539e79729..0cb130960 100644 --- a/hugolib/hugo_smoke_test.go +++ b/hugolib/hugo_smoke_test.go @@ -301,3 +301,33 @@ The content. b.CreateSites().Build(BuildCfg{}) } + +func TestBundleMany(t *testing.T) { + + b := newTestSitesBuilder(t).WithSimpleConfigFile() + for i := 1; i <= 50; i++ { + b.WithContent(fmt.Sprintf("bundle%d/index.md", i), fmt.Sprintf(` +--- +title: "Page %d" +--- + +`, i)) + b.WithSourceFile(fmt.Sprintf("content/bundle%d/data.yaml", i), fmt.Sprintf(` +data: v%d +`, i)) + } + + b.WithTemplatesAdded("_default/single.html", ` +{{ $yaml := .Resources.GetMatch "*.yaml" }} +{{ $data := $yaml | transform.Unmarshal }} +data content: {{ $yaml.Content | safeHTML }} +data unmarshaled: {{ $data.data }} +`) + + b.CreateSites().Build(BuildCfg{}) + + for i := 1; i <= 50; i++ { + b.AssertFileContent(fmt.Sprintf("public/bundle%d/data.yaml", i), fmt.Sprintf("data: v%d", i)) + b.AssertFileContent(fmt.Sprintf("public/bundle%d/index.html", i), fmt.Sprintf("data unmarshaled: v%d", i)) + } +} diff --git a/resources/resource.go b/resources/resource.go index 7e755bdbc..7f52a7135 100644 --- a/resources/resource.go +++ b/resources/resource.go @@ -213,7 +213,7 @@ func (l *genericResource) Data() interface{} { } func (l *genericResource) Key() string { - return l.relTargetDirFile.path() + return l.RelPermalink() } func (l *genericResource) MediaType() media.Type { diff --git a/resources/resource_test.go b/resources/resource_test.go index 46391527d..7a0b8069d 100644 --- a/resources/resource_test.go +++ b/resources/resource_test.go @@ -52,7 +52,7 @@ func TestGenericResourceWithLinkFacory(t *testing.T) { c.Assert(r.Permalink(), qt.Equals, "https://example.com/foo/foo.css") c.Assert(r.RelPermalink(), qt.Equals, "/foo/foo.css") - c.Assert(r.Key(), qt.Equals, "foo.css") + c.Assert(r.Key(), qt.Equals, "/foo/foo.css") c.Assert(r.ResourceType(), qt.Equals, "css") } |