mirror of
https://github.com/gohugoio/hugo.git
synced 2026-08-24 15:28:54 +00:00
Rename common/maps to common/hmaps (#14384)
Go's stdlid now has a maps package, which is very useful. We have been using imports on the form `xmaps "maps"`, but auto import tools doesn't handle this, which is annoying. I have been thinking about this for some time, but have been holding back because of all the import changes. However, now is a good time to do this, with very little unmerged code.
This commit is contained in:
committed by
GitHub
parent
94f1ede3aa
commit
608ed09a0a
@@ -14,20 +14,19 @@
|
||||
package resource
|
||||
|
||||
import (
|
||||
"github.com/gohugoio/hugo/common/maps"
|
||||
|
||||
"github.com/gohugoio/hugo/common/hmaps"
|
||||
"github.com/spf13/cast"
|
||||
)
|
||||
|
||||
func Param(r ResourceParamsProvider, fallback maps.Params, key any) (any, error) {
|
||||
func Param(r ResourceParamsProvider, fallback hmaps.Params, key any) (any, error) {
|
||||
keyStr, err := cast.ToStringE(key)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
if fallback == nil {
|
||||
return maps.GetNestedParam(keyStr, ".", r.Params())
|
||||
return hmaps.GetNestedParam(keyStr, ".", r.Params())
|
||||
}
|
||||
|
||||
return maps.GetNestedParam(keyStr, ".", r.Params(), fallback)
|
||||
return hmaps.GetNestedParam(keyStr, ".", r.Params(), fallback)
|
||||
}
|
||||
|
||||
@@ -17,8 +17,7 @@ import (
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
"github.com/gohugoio/hugo/common/maps"
|
||||
|
||||
"github.com/gohugoio/hugo/common/hmaps"
|
||||
"github.com/gohugoio/hugo/helpers"
|
||||
"github.com/pelletier/go-toml/v2"
|
||||
|
||||
@@ -38,7 +37,7 @@ func GetParamToLower(r Resource, key string) any {
|
||||
}
|
||||
|
||||
func getParam(r Resource, key string, stringToLower bool) any {
|
||||
v, err := maps.GetNestedParam(key, ".", r.Params())
|
||||
v, err := hmaps.GetNestedParam(key, ".", r.Params())
|
||||
|
||||
if v == nil || err != nil {
|
||||
return nil
|
||||
|
||||
@@ -20,8 +20,8 @@ import (
|
||||
"slices"
|
||||
"strings"
|
||||
|
||||
"github.com/gohugoio/hugo/common/hmaps"
|
||||
"github.com/gohugoio/hugo/common/hreflect"
|
||||
"github.com/gohugoio/hugo/common/maps"
|
||||
"github.com/gohugoio/hugo/common/paths"
|
||||
"github.com/gohugoio/hugo/hugofs/hglob"
|
||||
"github.com/spf13/cast"
|
||||
@@ -330,7 +330,7 @@ func NewCachedResourceGetter(os ...any) *cachedResourceGetter {
|
||||
}
|
||||
|
||||
return &cachedResourceGetter{
|
||||
cache: maps.NewCache[string, Resource](),
|
||||
cache: hmaps.NewCache[string, Resource](),
|
||||
delegate: getters,
|
||||
}
|
||||
}
|
||||
@@ -352,7 +352,7 @@ var (
|
||||
)
|
||||
|
||||
type cachedResourceGetter struct {
|
||||
cache *maps.Cache[string, Resource]
|
||||
cache *hmaps.Cache[string, Resource]
|
||||
delegate ResourceGetter
|
||||
}
|
||||
|
||||
|
||||
@@ -16,7 +16,7 @@ package resource
|
||||
import (
|
||||
"context"
|
||||
|
||||
"github.com/gohugoio/hugo/common/maps"
|
||||
"github.com/gohugoio/hugo/common/hmaps"
|
||||
"github.com/gohugoio/hugo/common/types"
|
||||
"github.com/gohugoio/hugo/langs"
|
||||
"github.com/gohugoio/hugo/media"
|
||||
@@ -139,7 +139,7 @@ type NameNormalizedProvider interface {
|
||||
|
||||
type ResourceParamsProvider interface {
|
||||
// Params set in front matter for this resource.
|
||||
Params() maps.Params
|
||||
Params() hmaps.Params
|
||||
}
|
||||
|
||||
type ResourceDataProvider interface {
|
||||
|
||||
Reference in New Issue
Block a user