diff options
author | Bjørn Erik Pedersen <[email protected]> | 2023-08-07 10:52:52 +0200 |
---|---|---|
committer | Bjørn Erik Pedersen <[email protected]> | 2023-08-07 13:42:54 +0200 |
commit | 851bf3515e61141cda6209fb196f4505c826607c (patch) | |
tree | 4c227fb57c849638059836a4f490d0c5c0da0a42 /config/allconfig | |
parent | d4a6c16c17b8804c13c9c0a5526be01fc238c67a (diff) | |
download | hugo-851bf3515e61141cda6209fb196f4505c826607c.tar.gz hugo-851bf3515e61141cda6209fb196f4505c826607c.zip |
Add all config to docshelper.json
Also consolidate so the mediaTypes and outputFormats are listed once only.
Fixes #11328
Diffstat (limited to 'config/allconfig')
-rw-r--r-- | config/allconfig/alldecoders.go | 13 | ||||
-rw-r--r-- | config/allconfig/docshelper.go | 49 |
2 files changed, 58 insertions, 4 deletions
diff --git a/config/allconfig/alldecoders.go b/config/allconfig/alldecoders.go index 6b8a4568c..24f9b9677 100644 --- a/config/allconfig/alldecoders.go +++ b/config/allconfig/alldecoders.go @@ -49,10 +49,11 @@ type decodeConfig struct { } type decodeWeight struct { - key string - decode func(decodeWeight, decodeConfig) error - getCompiler func(c *Config) configCompiler - weight int + key string + decode func(decodeWeight, decodeConfig) error + getCompiler func(c *Config) configCompiler + weight int + internalOrDeprecated bool // Hide it from the docs. } var allDecoderSetups = map[string]decodeWeight{ @@ -340,6 +341,7 @@ var allDecoderSetups = map[string]decodeWeight{ p.c.Author = maps.CleanConfigStringMap(p.p.GetStringMap(d.key)) return nil }, + internalOrDeprecated: true, }, "social": { key: "social", @@ -347,6 +349,7 @@ var allDecoderSetups = map[string]decodeWeight{ p.c.Social = maps.CleanConfigStringMapString(p.p.GetStringMapString(d.key)) return nil }, + internalOrDeprecated: true, }, "uglyurls": { key: "uglyurls", @@ -362,12 +365,14 @@ var allDecoderSetups = map[string]decodeWeight{ } return nil }, + internalOrDeprecated: true, }, "internal": { key: "internal", decode: func(d decodeWeight, p decodeConfig) error { return mapstructure.WeakDecode(p.p.GetStringMap(d.key), &p.c.Internal) }, + internalOrDeprecated: true, }, } diff --git a/config/allconfig/docshelper.go b/config/allconfig/docshelper.go new file mode 100644 index 000000000..48a09de51 --- /dev/null +++ b/config/allconfig/docshelper.go @@ -0,0 +1,49 @@ +// Copyright 2023 The Hugo Authors. All rights reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +package allconfig + +import ( + "github.com/gohugoio/hugo/common/maps" + "github.com/gohugoio/hugo/config" + "github.com/gohugoio/hugo/docshelper" +) + +// This is is just some helpers used to create some JSON used in the Hugo docs. +func init() { + docsProvider := func() docshelper.DocProvider { + + cfg := config.New() + for configRoot, v := range allDecoderSetups { + if v.internalOrDeprecated { + continue + } + cfg.Set(configRoot, make(maps.Params)) + } + lang := maps.Params{ + "en": maps.Params{ + "menus": maps.Params{}, + "params": maps.Params{}, + }, + } + cfg.Set("languages", lang) + cfg.SetDefaultMergeStrategy() + + configHelpers := map[string]any{ + "mergeStrategy": cfg.Get(""), + } + return docshelper.DocProvider{"config_helpers": configHelpers} + } + + docshelper.AddDocProviderFunc(docsProvider) +} |