mirror of
https://github.com/gohugoio/hugo.git
synced 2024-11-07 20:30:36 -05:00
hugolib: Fix simple menu config
This stopped working in Hugo 0.55: ```bash --- menu: "main" --- ``` This was also the case for using a slice of menu entries. This still worked: --- menu: main: weight: 30 ---
This commit is contained in:
parent
f7375c4972
commit
9e9a1f92ba
2 changed files with 53 additions and 2 deletions
|
@ -112,3 +112,54 @@ Menu Main: {{ partial "menu.html" (dict "page" . "menu" "main") }}`,
|
||||||
"/sect3/|Sect3s||0|-|-|")
|
"/sect3/|Sect3s||0|-|-|")
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func TestMenuFrontMatter(t *testing.T) {
|
||||||
|
|
||||||
|
b := newTestSitesBuilder(t).WithSimpleConfigFile()
|
||||||
|
|
||||||
|
b.WithTemplatesAdded("index.html", `
|
||||||
|
Main: {{ len .Site.Menus.main }}
|
||||||
|
Other: {{ len .Site.Menus.other }}
|
||||||
|
{{ range .Site.Menus.main }}
|
||||||
|
* Main|{{ .Name }}: {{ .URL }}
|
||||||
|
{{ end }}
|
||||||
|
{{ range .Site.Menus.other }}
|
||||||
|
* Other|{{ .Name }}: {{ .URL }}
|
||||||
|
{{ end }}
|
||||||
|
`)
|
||||||
|
|
||||||
|
// Issue #5828
|
||||||
|
b.WithContent("blog/page1.md", `
|
||||||
|
---
|
||||||
|
title: "P1"
|
||||||
|
menu: main
|
||||||
|
---
|
||||||
|
|
||||||
|
`)
|
||||||
|
|
||||||
|
b.WithContent("blog/page2.md", `
|
||||||
|
---
|
||||||
|
title: "P2"
|
||||||
|
menu: [main,other]
|
||||||
|
---
|
||||||
|
|
||||||
|
`)
|
||||||
|
|
||||||
|
b.WithContent("blog/page3.md", `
|
||||||
|
---
|
||||||
|
title: "P3"
|
||||||
|
menu:
|
||||||
|
main:
|
||||||
|
weight: 30
|
||||||
|
---
|
||||||
|
`)
|
||||||
|
|
||||||
|
b.Build(BuildCfg{})
|
||||||
|
|
||||||
|
b.AssertFileContent("public/index.html",
|
||||||
|
"Main: 3", "Other: 1",
|
||||||
|
"Main|P1: /blog/page1/",
|
||||||
|
"Other|P2: /blog/page2/",
|
||||||
|
)
|
||||||
|
|
||||||
|
}
|
||||||
|
|
|
@ -60,7 +60,7 @@ func PageMenusFromPage(p Page) (PageMenus, error) {
|
||||||
if err == nil {
|
if err == nil {
|
||||||
me.Menu = mname
|
me.Menu = mname
|
||||||
pm[mname] = &me
|
pm[mname] = &me
|
||||||
return nil, nil
|
return pm, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// Could be a slice of strings
|
// Could be a slice of strings
|
||||||
|
@ -71,7 +71,7 @@ func PageMenusFromPage(p Page) (PageMenus, error) {
|
||||||
me.Menu = mname
|
me.Menu = mname
|
||||||
pm[mname] = &me
|
pm[mname] = &me
|
||||||
}
|
}
|
||||||
return nil, nil
|
return pm, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// Could be a structured menu entry
|
// Could be a structured menu entry
|
||||||
|
|
Loading…
Reference in a new issue