@@ -227,3 +227,50 @@ eventDate: 2023-11-01T07:00:00-08:00
227
227
228
228
b .AssertFileContent ("public/index.html" , "2023-11|p9|p8|p7|2023-10|p6|p5|p4|2023-09|p3|p2|p1|" )
229
229
}
230
+
231
+ // Issue 10412
232
+ func TestImageTransformThenCopy (t * testing.T ) {
233
+ t .Parallel ()
234
+
235
+ files := `
236
+ -- hugo.toml --
237
+ disableKinds = ['page','rss','section','sitemap','taxonomy','term']
238
+ -- assets/pixel.png --
239
+ iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAADUlEQVR42mNkYPhfDwAChwGA60e6kgAAAABJRU5ErkJggg==
240
+ -- layouts/index.html --
241
+ {{- with resources.Get "pixel.png" }}
242
+ {{- with .Resize "200x" | resources.Copy "pixel.png" }}
243
+ <img src="{{ .RelPermalink }}" width="{{ .Width }}" height="{{ .Height }}">|{{ .Key }}
244
+ {{- end }}
245
+ {{- end }}
246
+ `
247
+
248
+ b := hugolib .Test (t , files )
249
+
250
+ b .AssertFileExists ("public/pixel.png" , true )
251
+ b .AssertFileContent ("public/index.html" ,
252
+ `<img src="/pixel.png" width="200" height="200">|/pixel.png` ,
253
+ )
254
+ }
255
+
256
+ // Issue 12310
257
+ func TestUseDifferentCacheKeyForResourceCopy (t * testing.T ) {
258
+ t .Parallel ()
259
+
260
+ files := `
261
+ -- hugo.toml --
262
+ disableKinds = ['page','section','rss','sitemap','taxonomy','term']
263
+ -- assets/a.txt --
264
+ This was assets/a.txt
265
+ -- layouts/index.html --
266
+ {{ $nilResource := resources.Get "/p1/b.txt" }}
267
+ {{ $r := resources.Get "a.txt" }}
268
+ {{ $r = resources.Copy "/p1/b.txt" $r }}
269
+ {{ $r.RelPermalink }}
270
+ `
271
+
272
+ b , err := hugolib .TestE (t , files )
273
+
274
+ b .Assert (err , qt .IsNil )
275
+ b .AssertFileContent ("public/p1/b.txt" , "This was assets/a.txt" )
276
+ }
0 commit comments