diff options
author | SatowTakeshi <[email protected]> | 2020-02-29 18:44:05 +0900 |
---|---|---|
committer | Bjørn Erik Pedersen <[email protected]> | 2020-03-20 20:35:57 +0100 |
commit | 574c2959b8d3338764fa1db102a5e0fd6ed322d9 (patch) | |
tree | 185d13348f474d1bb0bb2b0fbfd6bec9d11c8f5e /docshelper | |
parent | 99958f90fedec11d749a1397300860aa8e8459c2 (diff) | |
download | hugo-574c2959b8d3338764fa1db102a5e0fd6ed322d9.tar.gz hugo-574c2959b8d3338764fa1db102a5e0fd6ed322d9.zip |
Add minify config
Fixes #6750
Updates #6892
Diffstat (limited to 'docshelper')
-rw-r--r-- | docshelper/docs.go | 16 |
1 files changed, 15 insertions, 1 deletions
diff --git a/docshelper/docs.go b/docshelper/docs.go index 94cb70dec..17e0ccd91 100644 --- a/docshelper/docs.go +++ b/docshelper/docs.go @@ -24,7 +24,11 @@ var DocProviders = make(map[string]DocProvider) // AddDocProvider adds or updates the DocProvider for a given name. func AddDocProvider(name string, provider DocProvider) { - DocProviders[name] = provider + if prev, ok := DocProviders[name]; !ok { + DocProviders[name] = provider + } else { + DocProviders[name] = merge(prev, provider) + } } // DocProvider is used to save arbitrary JSON data @@ -35,3 +39,13 @@ type DocProvider func() map[string]interface{} func (d DocProvider) MarshalJSON() ([]byte, error) { return json.MarshalIndent(d(), "", " ") } + +func merge(a, b DocProvider) DocProvider { + next := a() + for k, v := range b() { + next[k] = v + } + return func() map[string]interface{} { + return next + } +} |