mirror of
https://github.com/gohugoio/hugo.git
synced 2025-08-29 22:29:56 +02:00
Split out the puthe path/filepath functions into common/paths
So they can be used from the config package without cyclic troubles. Updates #8654
This commit is contained in:
@@ -21,6 +21,7 @@ import (
|
||||
"github.com/gohugoio/hugo/common/types"
|
||||
|
||||
"github.com/gohugoio/hugo/common/maps"
|
||||
cpaths "github.com/gohugoio/hugo/common/paths"
|
||||
|
||||
"github.com/gobwas/glob"
|
||||
hglob "github.com/gohugoio/hugo/hugofs/glob"
|
||||
@@ -436,7 +437,7 @@ func (l configLoader) loadConfig(configName string) (string, error) {
|
||||
}
|
||||
|
||||
var filename string
|
||||
if helpers.ExtNoDelimiter(configName) != "" {
|
||||
if cpaths.ExtNoDelimiter(configName) != "" {
|
||||
exists, _ := helpers.Exists(baseFilename, l.Fs)
|
||||
if exists {
|
||||
filename = baseFilename
|
||||
@@ -509,7 +510,7 @@ func (l configLoader) loadConfigFromConfigDir() ([]string, error) {
|
||||
return nil
|
||||
}
|
||||
|
||||
name := helpers.Filename(filepath.Base(path))
|
||||
name := cpaths.Filename(filepath.Base(path))
|
||||
|
||||
item, err := metadecoders.Default.UnmarshalFileToMap(sourceFs, path)
|
||||
if err != nil {
|
||||
@@ -520,7 +521,7 @@ func (l configLoader) loadConfigFromConfigDir() ([]string, error) {
|
||||
|
||||
if name != "config" {
|
||||
// Can be params.jp, menus.en etc.
|
||||
name, lang := helpers.FileAndExtNoDelimiter(name)
|
||||
name, lang := cpaths.FileAndExtNoDelimiter(name)
|
||||
|
||||
keyPath = []string{name}
|
||||
|
||||
|
@@ -19,7 +19,7 @@ import (
|
||||
"strings"
|
||||
"testing"
|
||||
|
||||
"github.com/gohugoio/hugo/helpers"
|
||||
"github.com/gohugoio/hugo/common/paths"
|
||||
|
||||
"github.com/gohugoio/hugo/htesting/hqt"
|
||||
|
||||
@@ -112,7 +112,7 @@ func TestContentMap(t *testing.T) {
|
||||
meta["lang"] = lang
|
||||
meta["path"] = meta.Filename()
|
||||
meta["classifier"] = files.ClassifyContentFile(fi.Name(), meta.GetOpener())
|
||||
meta["translationBaseName"] = helpers.Filename(fi.Name())
|
||||
meta["translationBaseName"] = paths.Filename(fi.Name())
|
||||
})
|
||||
}
|
||||
|
||||
|
@@ -20,6 +20,8 @@ import (
|
||||
"strings"
|
||||
"sync"
|
||||
|
||||
"github.com/gohugoio/hugo/common/paths"
|
||||
|
||||
"github.com/gohugoio/hugo/hugofs/files"
|
||||
|
||||
"github.com/gohugoio/hugo/helpers"
|
||||
@@ -187,7 +189,7 @@ func (c *PageCollections) getSectionOrPage(ref string) (*contentNode, string) {
|
||||
langSuffix := "." + m.s.Lang()
|
||||
|
||||
// Trim both extension and any language code.
|
||||
name := helpers.PathNoExt(filename)
|
||||
name := paths.PathNoExt(filename)
|
||||
name = strings.TrimSuffix(name, langSuffix)
|
||||
|
||||
// These are reserved bundle names and will always be stored by their owning
|
||||
|
@@ -29,6 +29,8 @@ import (
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
"github.com/gohugoio/hugo/common/paths"
|
||||
|
||||
"github.com/gohugoio/hugo/common/constants"
|
||||
|
||||
"github.com/gohugoio/hugo/common/loggers"
|
||||
@@ -1418,7 +1420,7 @@ func (s *SiteInfo) createNodeMenuEntryURL(in string) string {
|
||||
menuEntryURL := in
|
||||
menuEntryURL = helpers.SanitizeURLKeepTrailingSlash(s.s.PathSpec.URLize(menuEntryURL))
|
||||
if !s.canonifyURLs {
|
||||
menuEntryURL = helpers.AddContextRoot(s.s.PathSpec.BaseURL.String(), menuEntryURL)
|
||||
menuEntryURL = paths.AddContextRoot(s.s.PathSpec.BaseURL.String(), menuEntryURL)
|
||||
}
|
||||
return menuEntryURL
|
||||
}
|
||||
|
Reference in New Issue
Block a user