mirror of
https://github.com/gohugoio/hugo.git
synced 2025-08-29 22:29:56 +02:00
Fix Params case handling in the index, sort and where func
This means that you can now do: ``` {{ range where .Site.Pages "Params.MYPARAM" "foo" }} ```
This commit is contained in:
@@ -19,12 +19,16 @@ import (
|
||||
"github.com/spf13/cast"
|
||||
)
|
||||
|
||||
func Param(r ResourceParamsProvider, fallback map[string]interface{}, key interface{}) (interface{}, error) {
|
||||
func Param(r ResourceParamsProvider, fallback maps.Params, key interface{}) (interface{}, error) {
|
||||
keyStr, err := cast.ToStringE(key)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
if fallback == nil {
|
||||
return maps.GetNestedParam(keyStr, ".", r.Params())
|
||||
}
|
||||
|
||||
return maps.GetNestedParam(keyStr, ".", r.Params(), fallback)
|
||||
|
||||
}
|
||||
|
@@ -14,6 +14,7 @@
|
||||
package resource
|
||||
|
||||
import (
|
||||
"github.com/gohugoio/hugo/common/maps"
|
||||
"github.com/gohugoio/hugo/langs"
|
||||
"github.com/gohugoio/hugo/media"
|
||||
"github.com/gohugoio/hugo/resources/images/exif"
|
||||
@@ -85,7 +86,7 @@ type ResourceMetaProvider interface {
|
||||
|
||||
type ResourceParamsProvider interface {
|
||||
// Params set in front matter for this resource.
|
||||
Params() map[string]interface{}
|
||||
Params() maps.Params
|
||||
}
|
||||
|
||||
type ResourceDataProvider interface {
|
||||
|
Reference in New Issue
Block a user