mirror of
https://github.com/gohugoio/hugo.git
synced 2025-08-30 22:39:58 +02:00
@@ -19,7 +19,7 @@ import (
|
||||
"github.com/spf13/cast"
|
||||
)
|
||||
|
||||
func Param(r ResourceParamsProvider, fallback maps.Params, key interface{}) (interface{}, error) {
|
||||
func Param(r ResourceParamsProvider, fallback maps.Params, key any) (any, error) {
|
||||
keyStr, err := cast.ToStringE(key)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
|
@@ -24,17 +24,17 @@ import (
|
||||
|
||||
// GetParam will return the param with the given key from the Resource,
|
||||
// nil if not found.
|
||||
func GetParam(r Resource, key string) interface{} {
|
||||
func GetParam(r Resource, key string) any {
|
||||
return getParam(r, key, false)
|
||||
}
|
||||
|
||||
// GetParamToLower is the same as GetParam but it will lower case any string
|
||||
// result, including string slices.
|
||||
func GetParamToLower(r Resource, key string) interface{} {
|
||||
func GetParamToLower(r Resource, key string) any {
|
||||
return getParam(r, key, true)
|
||||
}
|
||||
|
||||
func getParam(r Resource, key string, stringToLower bool) interface{} {
|
||||
func getParam(r Resource, key string, stringToLower bool) any {
|
||||
v := r.Params()[strings.ToLower(key)]
|
||||
|
||||
if v == nil {
|
||||
@@ -60,9 +60,9 @@ func getParam(r Resource, key string, stringToLower bool) interface{} {
|
||||
return helpers.SliceToLower(val)
|
||||
}
|
||||
return v
|
||||
case map[string]interface{}: // JSON and TOML
|
||||
case map[string]any:
|
||||
return v
|
||||
case map[interface{}]interface{}: // YAML
|
||||
case map[any]any:
|
||||
return v
|
||||
}
|
||||
|
||||
|
@@ -108,7 +108,7 @@ func (r Resources) MergeByLanguage(r2 Resources) Resources {
|
||||
|
||||
// MergeByLanguageInterface is the generic version of MergeByLanguage. It
|
||||
// is here just so it can be called from the tpl package.
|
||||
func (r Resources) MergeByLanguageInterface(in interface{}) (interface{}, error) {
|
||||
func (r Resources) MergeByLanguageInterface(in any) (any, error) {
|
||||
r2, ok := in.(Resources)
|
||||
if !ok {
|
||||
return nil, fmt.Errorf("%T cannot be merged by language", in)
|
||||
|
@@ -66,7 +66,7 @@ type ImageOps interface {
|
||||
Fill(spec string) (Image, error)
|
||||
Fit(spec string) (Image, error)
|
||||
Resize(spec string) (Image, error)
|
||||
Filter(filters ...interface{}) (Image, error)
|
||||
Filter(filters ...any) (Image, error)
|
||||
Exif() *exif.Exif
|
||||
|
||||
// Internal
|
||||
@@ -119,7 +119,7 @@ type ResourceParamsProvider interface {
|
||||
type ResourceDataProvider interface {
|
||||
// Resource specific data set by Hugo.
|
||||
// One example would be.Data.Digest for fingerprinted resources.
|
||||
Data() interface{}
|
||||
Data() any
|
||||
}
|
||||
|
||||
// ResourcesLanguageMerger describes an interface for merging resources from a
|
||||
@@ -127,7 +127,7 @@ type ResourceDataProvider interface {
|
||||
type ResourcesLanguageMerger interface {
|
||||
MergeByLanguage(other Resources) Resources
|
||||
// Needed for integration with the tpl package.
|
||||
MergeByLanguageInterface(other interface{}) (interface{}, error)
|
||||
MergeByLanguageInterface(other any) (any, error)
|
||||
}
|
||||
|
||||
// Identifier identifies a resource.
|
||||
@@ -152,7 +152,7 @@ type ContentProvider interface {
|
||||
// * Page: template.HTML
|
||||
// * JSON: String
|
||||
// * Etc.
|
||||
Content() (interface{}, error)
|
||||
Content() (any, error)
|
||||
}
|
||||
|
||||
// OpenReadSeekCloser allows setting some other way (than reading from a filesystem)
|
||||
|
Reference in New Issue
Block a user