mirror of
https://github.com/gohugoio/hugo.git
synced 2024-11-21 20:46:30 -05:00
parent
3286b24fce
commit
3d058a936f
2 changed files with 57 additions and 0 deletions
|
@ -1018,6 +1018,8 @@ func (p *Page) update(f interface{}) error {
|
||||||
p.Params[loki] = vvv
|
p.Params[loki] = vvv
|
||||||
case map[string]interface{}: // Proper parsing structured array from JSON based FrontMatter
|
case map[string]interface{}: // Proper parsing structured array from JSON based FrontMatter
|
||||||
p.Params[loki] = vvv
|
p.Params[loki] = vvv
|
||||||
|
case []interface{}:
|
||||||
|
p.Params[loki] = vvv
|
||||||
default:
|
default:
|
||||||
a := make([]string, len(vvv))
|
a := make([]string, len(vvv))
|
||||||
for i, u := range vvv {
|
for i, u := range vvv {
|
||||||
|
|
|
@ -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) {
|
func TestPageSimpleMethods(t *testing.T) {
|
||||||
for i, this := range []struct {
|
for i, this := range []struct {
|
||||||
assertFunc func(p *Page) bool
|
assertFunc func(p *Page) bool
|
||||||
|
|
Loading…
Reference in a new issue