diff options
Diffstat (limited to 'hugofs/walk.go')
-rw-r--r-- | hugofs/walk.go | 10 |
1 files changed, 8 insertions, 2 deletions
diff --git a/hugofs/walk.go b/hugofs/walk.go index 391f70a65..4af46d89e 100644 --- a/hugofs/walk.go +++ b/hugofs/walk.go @@ -23,6 +23,7 @@ import ( "github.com/gohugoio/hugo/common/herrors" "github.com/gohugoio/hugo/common/loggers" "github.com/gohugoio/hugo/common/paths" + "github.com/gohugoio/hugo/media" "github.com/spf13/afero" ) @@ -50,7 +51,8 @@ type WalkwayConfig struct { Root string // The logger to use. - Logger loggers.Logger + Logger loggers.Logger + PathParser *paths.PathParser // One or both of these may be pre-set. Info FileMetaInfo // The start info. @@ -72,6 +74,10 @@ func NewWalkway(cfg WalkwayConfig) *Walkway { panic("fs must be set") } + if cfg.PathParser == nil { + cfg.PathParser = media.DefaultPathParser + } + logger := cfg.Logger if logger == nil { logger = loggers.NewDefault() @@ -161,7 +167,7 @@ func (w *Walkway) walk(path string, info FileMetaInfo, dirEntries []FileMetaInfo dirEntries = DirEntriesToFileMetaInfos(fis) for _, fi := range dirEntries { if fi.Meta().PathInfo == nil { - fi.Meta().PathInfo = paths.Parse("", filepath.Join(pathRel, fi.Name())) + fi.Meta().PathInfo = w.cfg.PathParser.Parse("", filepath.Join(pathRel, fi.Name())) } } |