mirror of
https://github.com/gohugoio/hugo.git
synced 2024-07-01 01:17:13 +00:00
parent
6dec671fb9
commit
c262a95a5c
|
@ -1232,23 +1232,31 @@ weight: %d
|
||||||
|
|
||||||
`, i))
|
`, i))
|
||||||
b.WithSourceFile(fmt.Sprintf("content/bundle%d/data.yaml", i), fmt.Sprintf(`data: v%d`, i))
|
b.WithSourceFile(fmt.Sprintf("content/bundle%d/data.yaml", i), fmt.Sprintf(`data: v%d`, i))
|
||||||
|
b.WithSourceFile(fmt.Sprintf("content/bundle%d/data.json", i), fmt.Sprintf(`{ "data": "v%d" }`, i))
|
||||||
b.WithSourceFile(fmt.Sprintf("assets/data%d/data.yaml", i), fmt.Sprintf(`vdata: v%d`, i))
|
b.WithSourceFile(fmt.Sprintf("assets/data%d/data.yaml", i), fmt.Sprintf(`vdata: v%d`, i))
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
b.WithTemplatesAdded("_default/single.html", `
|
b.WithTemplatesAdded("_default/single.html", `
|
||||||
{{ $bundleYaml := .Resources.GetMatch "*.yaml" }}
|
{{ $bundleYaml := .Resources.GetMatch "*.yaml" }}
|
||||||
|
{{ $bundleJSON := .Resources.GetMatch "*.json" }}
|
||||||
{{ $assetsYaml := resources.GetMatch (printf "data%d/*.yaml" .Weight) }}
|
{{ $assetsYaml := resources.GetMatch (printf "data%d/*.yaml" .Weight) }}
|
||||||
{{ $data1 := $bundleYaml | transform.Unmarshal }}
|
{{ $data1 := $bundleYaml | transform.Unmarshal }}
|
||||||
{{ $data2 := $assetsYaml | transform.Unmarshal }}
|
{{ $data2 := $assetsYaml | transform.Unmarshal }}
|
||||||
{{ $bundleFingerprinted := $bundleYaml | fingerprint "md5" }}
|
{{ $bundleFingerprinted := $bundleYaml | fingerprint "md5" }}
|
||||||
{{ $assetsFingerprinted := $assetsYaml | fingerprint "md5" }}
|
{{ $assetsFingerprinted := $assetsYaml | fingerprint "md5" }}
|
||||||
|
{{ $jsonMin := $bundleJSON | minify }}
|
||||||
|
{{ $jsonMinMin := $jsonMin | minify }}
|
||||||
|
{{ $jsonMinMinMin := $jsonMinMin | minify }}
|
||||||
|
|
||||||
data content unmarshaled: {{ $data1.data }}
|
data content unmarshaled: {{ $data1.data }}
|
||||||
data assets content unmarshaled: {{ $data2.vdata }}
|
data assets content unmarshaled: {{ $data2.vdata }}
|
||||||
bundle fingerprinted: {{ $bundleFingerprinted.RelPermalink }}
|
bundle fingerprinted: {{ $bundleFingerprinted.RelPermalink }}
|
||||||
assets fingerprinted: {{ $assetsFingerprinted.RelPermalink }}
|
assets fingerprinted: {{ $assetsFingerprinted.RelPermalink }}
|
||||||
|
|
||||||
|
bundle min min min: {{ $jsonMinMinMin.RelPermalink }}
|
||||||
|
bundle min min key: {{ $jsonMinMin.Key }}
|
||||||
|
|
||||||
`)
|
`)
|
||||||
|
|
||||||
for i := 0; i < 3; i++ {
|
for i := 0; i < 3; i++ {
|
||||||
|
@ -1256,18 +1264,27 @@ assets fingerprinted: {{ $assetsFingerprinted.RelPermalink }}
|
||||||
b.Build(BuildCfg{})
|
b.Build(BuildCfg{})
|
||||||
|
|
||||||
for i := 1; i <= 50; i++ {
|
for i := 1; i <= 50; i++ {
|
||||||
|
index := fmt.Sprintf("public/bundle%d/index.html", i)
|
||||||
b.AssertFileContent(fmt.Sprintf("public/bundle%d/data.yaml", i), fmt.Sprintf("data: v%d", 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 content unmarshaled: v%d", i))
|
b.AssertFileContent(index, fmt.Sprintf("data content unmarshaled: v%d", i))
|
||||||
b.AssertFileContent(fmt.Sprintf("public/bundle%d/index.html", i), fmt.Sprintf("data assets content unmarshaled: v%d", i))
|
b.AssertFileContent(index, fmt.Sprintf("data assets content unmarshaled: v%d", i))
|
||||||
|
|
||||||
md5Asset := helpers.MD5String(fmt.Sprintf(`vdata: v%d`, i))
|
md5Asset := helpers.MD5String(fmt.Sprintf(`vdata: v%d`, i))
|
||||||
b.AssertFileContent(fmt.Sprintf("public/bundle%d/index.html", i), fmt.Sprintf("assets fingerprinted: /data%d/data.%s.yaml", i, md5Asset))
|
b.AssertFileContent(index, fmt.Sprintf("assets fingerprinted: /data%d/data.%s.yaml", i, md5Asset))
|
||||||
|
|
||||||
// The original is not used, make sure it's not published.
|
// The original is not used, make sure it's not published.
|
||||||
b.Assert(b.CheckExists(fmt.Sprintf("public/data%d/data.yaml", i)), qt.Equals, false)
|
b.Assert(b.CheckExists(fmt.Sprintf("public/data%d/data.yaml", i)), qt.Equals, false)
|
||||||
|
|
||||||
md5Bundle := helpers.MD5String(fmt.Sprintf(`data: v%d`, i))
|
md5Bundle := helpers.MD5String(fmt.Sprintf(`data: v%d`, i))
|
||||||
b.AssertFileContent(fmt.Sprintf("public/bundle%d/index.html", i), fmt.Sprintf("bundle fingerprinted: /bundle%d/data.%s.yaml", i, md5Bundle))
|
b.AssertFileContent(index, fmt.Sprintf("bundle fingerprinted: /bundle%d/data.%s.yaml", i, md5Bundle))
|
||||||
|
|
||||||
|
b.AssertFileContent(index,
|
||||||
|
fmt.Sprintf("bundle min min min: /bundle%d/data.min.min.min.json", i),
|
||||||
|
fmt.Sprintf("bundle min min key: /bundle%d/data.min.min.json", i),
|
||||||
|
)
|
||||||
|
b.Assert(b.CheckExists(fmt.Sprintf("public/bundle%d/data.min.min.min.json", i)), qt.Equals, true)
|
||||||
|
b.Assert(b.CheckExists(fmt.Sprintf("public/bundle%d/data.min.json", i)), qt.Equals, false)
|
||||||
|
b.Assert(b.CheckExists(fmt.Sprintf("public/bundle%d/data.min.min.json", i)), qt.Equals, false)
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue