mirror of
https://github.com/gohugoio/hugo.git
synced 2024-11-21 20:46:30 -05:00
parent
671f64b2eb
commit
d595419031
2 changed files with 16 additions and 0 deletions
|
@ -23,6 +23,7 @@ import (
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/gohugoio/hugo/common/maps"
|
"github.com/gohugoio/hugo/common/maps"
|
||||||
|
"github.com/spf13/cast"
|
||||||
|
|
||||||
"github.com/gohugoio/hugo/common/types"
|
"github.com/gohugoio/hugo/common/types"
|
||||||
"github.com/mitchellh/mapstructure"
|
"github.com/mitchellh/mapstructure"
|
||||||
|
@ -283,6 +284,8 @@ func (cfg IndexConfig) ToKeywords(v any) ([]Keyword, error) {
|
||||||
vv = vc
|
vv = vc
|
||||||
}
|
}
|
||||||
keywords = append(keywords, StringsToKeywords(vv...)...)
|
keywords = append(keywords, StringsToKeywords(vv...)...)
|
||||||
|
case []any:
|
||||||
|
return cfg.ToKeywords(cast.ToStringSlice(vv))
|
||||||
case time.Time:
|
case time.Time:
|
||||||
layout := "2006"
|
layout := "2006"
|
||||||
if cfg.Pattern != "" {
|
if cfg.Pattern != "" {
|
||||||
|
|
|
@ -212,6 +212,19 @@ func TestToKeywordsToLower(t *testing.T) {
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func TestToKeywordsAnySlice(t *testing.T) {
|
||||||
|
c := qt.New(t)
|
||||||
|
var config IndexConfig
|
||||||
|
slice := []any{"A", 32, "C"}
|
||||||
|
keywords, err := config.ToKeywords(slice)
|
||||||
|
c.Assert(err, qt.IsNil)
|
||||||
|
c.Assert(keywords, qt.DeepEquals, []Keyword{
|
||||||
|
StringKeyword("A"),
|
||||||
|
StringKeyword("32"),
|
||||||
|
StringKeyword("C"),
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
func BenchmarkRelatedNewIndex(b *testing.B) {
|
func BenchmarkRelatedNewIndex(b *testing.B) {
|
||||||
pages := make([]*testDoc, 100)
|
pages := make([]*testDoc, 100)
|
||||||
numkeywords := 30
|
numkeywords := 30
|
||||||
|
|
Loading…
Reference in a new issue