Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/gohugoio/hugo.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--hugolib/menu_test.go51
-rw-r--r--navigation/pagemenus.go4
2 files changed, 53 insertions, 2 deletions
diff --git a/hugolib/menu_test.go b/hugolib/menu_test.go
index 253259af1..5c692d2e7 100644
--- a/hugolib/menu_test.go
+++ b/hugolib/menu_test.go
@@ -112,3 +112,54 @@ Menu Main: {{ partial "menu.html" (dict "page" . "menu" "main") }}`,
"/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/",
+ )
+
+}
diff --git a/navigation/pagemenus.go b/navigation/pagemenus.go
index 86a4aeaec..c0d809ee3 100644
--- a/navigation/pagemenus.go
+++ b/navigation/pagemenus.go
@@ -60,7 +60,7 @@ func PageMenusFromPage(p Page) (PageMenus, error) {
if err == nil {
me.Menu = mname
pm[mname] = &me
- return nil, nil
+ return pm, nil
}
// Could be a slice of strings
@@ -71,7 +71,7 @@ func PageMenusFromPage(p Page) (PageMenus, error) {
me.Menu = mname
pm[mname] = &me
}
- return nil, nil
+ return pm, nil
}
// Could be a structured menu entry