summaryrefslogtreecommitdiffstats
path: root/hugolib/menu_test.go
diff options
context:
space:
mode:
authorDavid Jones <david@davidejones.com>2020-11-22 13:09:59 -0800
committerGitHub <noreply@github.com>2020-11-22 22:09:59 +0100
commit8f5c9a747fcebb02bb99f5de272046411eb15370 (patch)
treeda9d219c001c2ddccafe8f5c5d05d962bf8c6275 /hugolib/menu_test.go
parente4fcb672ed8bae21fd9780292b54fea3040dd877 (diff)
Add menu params
Fixes #7951
Diffstat (limited to 'hugolib/menu_test.go')
-rw-r--r--hugolib/menu_test.go50
1 files changed, 50 insertions, 0 deletions
diff --git a/hugolib/menu_test.go b/hugolib/menu_test.go
index 6fa31b4ee..cfb4b954b 100644
--- a/hugolib/menu_test.go
+++ b/hugolib/menu_test.go
@@ -267,3 +267,53 @@ menu:
b.AssertFileContent("public/index.html", "A|Children:C|B|")
}
+
+func TestMenuParams(t *testing.T) {
+
+ b := newTestSitesBuilder(t).WithSimpleConfigFile()
+
+ b.WithTemplatesAdded("index.html", `
+Main: {{ len .Site.Menus.main }}
+{{ range .Site.Menus.main }}
+* Main|{{ .Name }}: {{ .URL }}|{{ .Params }}
+{{ end }}
+`)
+
+ b.WithContent("blog/page1.md", `
+---
+title: "P1"
+menu: main
+---
+
+`)
+
+ b.WithContent("blog/page2.md", `
+---
+title: "P2"
+menu: main
+---
+
+`)
+
+ b.WithContent("blog/page3.md", `
+---
+title: "P3"
+menu:
+ main:
+ weight: 30
+ params:
+ foo: "bar"
+ key2: "value2"
+---
+`)
+
+ b.Build(BuildCfg{})
+
+ b.AssertFileContent("public/index.html",
+ "Main: 3",
+ "Main|P3: /blog/page3/|map[foo:bar key2:value2]",
+ "Main|P1: /blog/page1/|map[]",
+ "Main|P2: /blog/page2/|map[]",
+ )
+
+}