mirror of
https://github.com/gohugoio/hugo.git
synced 2025-08-30 22:39:58 +02:00
Rework the build.writeStats struct
Mostly to make it easier to toggle on/off this feature from the env. See #11191
This commit is contained in:
@@ -475,7 +475,7 @@ func (h *HugoSites) writeBuildStats() error {
|
||||
if h.ResourceSpec == nil {
|
||||
panic("h.ResourceSpec is nil")
|
||||
}
|
||||
if !h.ResourceSpec.BuildConfig().WriteStats.Enabled() {
|
||||
if !h.ResourceSpec.BuildConfig().BuildStats.Enabled() {
|
||||
return nil
|
||||
}
|
||||
|
||||
|
@@ -1200,46 +1200,39 @@ writeStats = false
|
||||
b.AssertDestinationExists("hugo_stats.json", false)
|
||||
|
||||
b = r(`
|
||||
[build.writeStats]
|
||||
tags = true
|
||||
classes = true
|
||||
ids = true
|
||||
`)
|
||||
[build.buildStats]
|
||||
enable = true
|
||||
`)
|
||||
|
||||
b.AssertFileContent("hugo_stats.json", "myclass", "div", "myid")
|
||||
|
||||
b = r(`
|
||||
[build.writeStats]
|
||||
tags = true
|
||||
classes = true
|
||||
ids = false
|
||||
[build.buildStats]
|
||||
enable = true
|
||||
disableids = true
|
||||
`)
|
||||
|
||||
b.AssertFileContent("hugo_stats.json", "myclass", "div", "! myid")
|
||||
|
||||
b = r(`
|
||||
[build.writeStats]
|
||||
tags = true
|
||||
classes = false
|
||||
ids = true
|
||||
[build.buildStats]
|
||||
enable = true
|
||||
disableclasses = true
|
||||
`)
|
||||
|
||||
b.AssertFileContent("hugo_stats.json", "! myclass", "div", "myid")
|
||||
|
||||
b = r(`
|
||||
[build.writeStats]
|
||||
tags = false
|
||||
classes = true
|
||||
ids = true
|
||||
[build.buildStats]
|
||||
enable = true
|
||||
disabletags = true
|
||||
`)
|
||||
|
||||
b.AssertFileContent("hugo_stats.json", "myclass", "! div", "myid")
|
||||
|
||||
b = r(`
|
||||
[build.writeStats]
|
||||
tags = false
|
||||
classes = false
|
||||
ids = false
|
||||
[build.buildStats]
|
||||
enable = false
|
||||
`)
|
||||
b.AssertDestinationExists("hugo_stats.json", false)
|
||||
|
||||
|
Reference in New Issue
Block a user