Avoid escaping HTML chars inside hugo_stats.json

Fixes #11371
This commit is contained in:
Bjørn Erik Pedersen
2023-08-21 10:48:28 +02:00
parent b6538532f4
commit bcf7421ea5
2 changed files with 8 additions and 2 deletions

View File

@@ -492,10 +492,15 @@ func (h *HugoSites) writeBuildStats() error {
HTMLElements: *htmlElements,
}
js, err := json.MarshalIndent(stats, "", " ")
var buf bytes.Buffer
enc := json.NewEncoder(&buf)
enc.SetEscapeHTML(false)
enc.SetIndent("", " ")
err := enc.Encode(stats)
if err != nil {
return err
}
js := buf.Bytes()
filename := filepath.Join(h.Configs.LoadingInfo.BaseConfig.WorkingDir, files.FilenameHugoStatsJSON)