summaryrefslogtreecommitdiffstats
path: root/config
diff options
context:
space:
mode:
authorBjørn Erik Pedersen <bjorn.erik.pedersen@gmail.com>2023-07-02 11:02:47 +0200
committerBjørn Erik Pedersen <bjorn.erik.pedersen@gmail.com>2023-07-02 13:04:11 +0200
commit5afc89f2bfb3e582bface8a9980e60782ece9880 (patch)
tree325ac10ec7f26da64d7e20f11219d91428f64dba /config
parentc1eac616d55945c28ea364f44d1e9ae12e672e11 (diff)
Rework the build.writeStats struct
Mostly to make it easier to toggle on/off this feature from the env. See #11191
Diffstat (limited to 'config')
-rw-r--r--config/commonConfig.go28
1 files changed, 14 insertions, 14 deletions
diff --git a/config/commonConfig.go b/config/commonConfig.go
index 037499465..2c6497b34 100644
--- a/config/commonConfig.go
+++ b/config/commonConfig.go
@@ -82,7 +82,7 @@ type LoadConfigResult struct {
var defaultBuild = BuildConfig{
UseResourceCacheWhen: "fallback",
- WriteStats: WriteStats{},
+ BuildStats: BuildStats{},
CacheBusters: []CacheBuster{
{
@@ -112,7 +112,7 @@ type BuildConfig struct {
// When enabled, will collect and write a hugo_stats.json with some build
// related aggregated data (e.g. CSS class names).
// Note that this was a bool <= v0.115.0.
- WriteStats WriteStats
+ BuildStats BuildStats
// Can be used to toggle off writing of the IntelliSense /assets/jsconfig.js
// file.
@@ -122,15 +122,19 @@ type BuildConfig struct {
CacheBusters []CacheBuster
}
-// WriteStats configures what to write to the hugo_stats.json file.
-type WriteStats struct {
- Tags bool
- Classes bool
- IDs bool
+// BuildStats configures if and what to write to the hugo_stats.json file.
+type BuildStats struct {
+ Enable bool
+ DisableTags bool
+ DisableClasses bool
+ DisableIDs bool
}
-func (w WriteStats) Enabled() bool {
- return w.Tags || w.Classes || w.IDs
+func (w BuildStats) Enabled() bool {
+ if !w.Enable {
+ return false
+ }
+ return !w.DisableTags || !w.DisableClasses || !w.DisableIDs
}
func (b BuildConfig) clone() BuildConfig {
@@ -192,11 +196,7 @@ func DecodeBuildConfig(cfg Provider) BuildConfig {
// writeStats was a bool <= v0.115.0.
if writeStats, ok := m["writestats"]; ok {
if bb, ok := writeStats.(bool); ok {
- m["writestats"] = WriteStats{
- Tags: bb,
- Classes: bb,
- IDs: bb,
- }
+ m["buildstats"] = BuildStats{Enable: bb}
}
}