diff --git a/hugolib/page.go b/hugolib/page.go index fa46ed77b..50c10e935 100644 --- a/hugolib/page.go +++ b/hugolib/page.go @@ -1018,6 +1018,8 @@ func (p *Page) update(f interface{}) error { p.Params[loki] = vvv case map[string]interface{}: // Proper parsing structured array from JSON based FrontMatter p.Params[loki] = vvv + case []interface{}: + p.Params[loki] = vvv default: a := make([]string, len(vvv)) for i, u := range vvv { diff --git a/hugolib/page_test.go b/hugolib/page_test.go index 2098063b4..9de2898d5 100644 --- a/hugolib/page_test.go +++ b/hugolib/page_test.go @@ -1261,6 +1261,61 @@ func TestDraft(t *testing.T) { } } +var pagesParamsTemplate = []string{`+++ +title = "okay" +draft = false +tags = [ "hugo", "web" ] +social= [ + [ "a", "#" ], + [ "b", "#" ], +] ++++ +some content +`, + `--- +title: "okay" +draft: false +tags: + - hugo + - web +social: + - - a + - "#" + - - b + - "#" +--- +some content +`, + `{ + "title": "okay", + "draft": false, + "tags": [ "hugo", "web" ], + "social": [ + [ "a", "#" ], + [ "b", "#" ] + ] +} +some content +`, +} + +func TestPageParams(t *testing.T) { + want := map[string]interface{}{ + "tags": []string{"hugo", "web"}, + // Issue #2752 + "social": []interface{}{ + []interface{}{"a", "#"}, + []interface{}{"b", "#"}, + }, + } + + for i, c := range pagesParamsTemplate { + p, err := NewPageFrom(strings.NewReader(c), "content/post/params.md") + require.NoError(t, err, "err during parse", "#%d", i) + assert.Equal(t, want, p.Params, "#%d", i) + } +} + func TestPageSimpleMethods(t *testing.T) { for i, this := range []struct { assertFunc func(p *Page) bool