1
0
mirror of https://github.com/gohugoio/hugo.git synced 2024-05-11 05:54:58 +00:00

Create a struct with all of Hugo's config options

Primary motivation is documentation, but it will also hopefully simplify the code.

Also,

* Lower case the default output format names; this is in line with the custom ones (map keys) and how
it's treated all the places. This avoids doing `stringds.EqualFold` everywhere.

Closes #10896
Closes #10620
This commit is contained in:
Bjørn Erik Pedersen
2023-01-04 18:24:36 +01:00
parent 6aededf6b4
commit 241b21b0fd
337 changed files with 13377 additions and 14898 deletions

View File

@@ -18,6 +18,7 @@ import (
"github.com/gohugoio/hugo/common/maps"
"github.com/gohugoio/hugo/common/types"
"github.com/mitchellh/mapstructure"
"github.com/spf13/cast"
)
@@ -54,7 +55,8 @@ func PageMenusFromPage(p Page) (PageMenus, error) {
return nil, nil
}
me := MenuEntry{Page: p, Name: p.LinkTitle(), Weight: p.Weight()}
me := MenuEntry{}
SetPageValues(&me, p)
// Could be the name of the menu to attach it to
mname, err := cast.ToStringE(ms)
@@ -87,17 +89,17 @@ func PageMenusFromPage(p Page) (PageMenus, error) {
}
for name, menu := range menus {
menuEntry := MenuEntry{Page: p, Name: p.LinkTitle(), Weight: p.Weight(), Menu: name}
menuEntry := MenuEntry{Menu: name}
if menu != nil {
ime, err := maps.ToStringMapE(menu)
if err != nil {
return pm, wrapErr(err)
}
if err = menuEntry.MarshallMap(ime); err != nil {
return pm, wrapErr(err)
if err := mapstructure.WeakDecode(ime, &menuEntry.MenuConfig); err != nil {
return pm, err
}
}
SetPageValues(&menuEntry, p)
pm[name] = &menuEntry
}