diff options
author | Bjørn Erik Pedersen <bjorn.erik.pedersen@gmail.com> | 2021-11-16 19:54:41 +0100 |
---|---|---|
committer | Bjørn Erik Pedersen <bjorn.erik.pedersen@gmail.com> | 2021-11-16 20:42:34 +0100 |
commit | 2e70f61fb04cea08ef6598728a57637ae2cc199c (patch) | |
tree | 8e975b19634eacf3dbfb5197e5ff1b2be7fb3040 | |
parent | 1ed8069a3a592dbbd493778a9637fb13727f4c61 (diff) |
Fix content dir resolution when main project is a Hugo Module
Fixes #9177
-rw-r--r-- | hugofs/fileinfo.go | 1 | ||||
-rw-r--r-- | hugofs/rootmapping_fs.go | 2 | ||||
-rw-r--r-- | hugolib/filesystems/basefs.go | 5 |
3 files changed, 6 insertions, 2 deletions
diff --git a/hugofs/fileinfo.go b/hugofs/fileinfo.go index ea6ac4fd3..0a958a0c5 100644 --- a/hugofs/fileinfo.go +++ b/hugofs/fileinfo.go @@ -64,6 +64,7 @@ type FileMeta struct { IsOrdered bool IsSymlink bool IsRootFile bool + IsProject bool Watch bool Classifier files.ContentClass diff --git a/hugofs/rootmapping_fs.go b/hugofs/rootmapping_fs.go index bd10144ff..9fdce3ad7 100644 --- a/hugofs/rootmapping_fs.go +++ b/hugofs/rootmapping_fs.go @@ -62,6 +62,7 @@ func NewRootMappingFs(fs afero.Fs, rms ...RootMapping) (*RootMappingFs, error) { rm.Meta.BaseDir = rm.ToBasedir rm.Meta.MountRoot = rm.path rm.Meta.Module = rm.Module + rm.Meta.IsProject = rm.IsProject meta := rm.Meta.Copy() @@ -118,6 +119,7 @@ type RootMapping struct { To string // The source directory or file. ToBasedir string // The base of To. May be empty if an absolute path was provided. Module string // The module path/ID. + IsProject bool // Whether this is a mount in the main project. Meta *FileMeta // File metadata (lang etc.) fi FileMetaInfo diff --git a/hugolib/filesystems/basefs.go b/hugolib/filesystems/basefs.go index be765ef9d..a51cc4b27 100644 --- a/hugolib/filesystems/basefs.go +++ b/hugolib/filesystems/basefs.go @@ -136,7 +136,7 @@ func (b *BaseFs) AbsProjectContentDir(filename string) (string, string, error) { isAbs := filepath.IsAbs(filename) for _, dir := range b.SourceFilesystems.Content.Dirs { meta := dir.Meta() - if meta.Module != "project" { + if !meta.IsProject { continue } if isAbs { @@ -161,7 +161,7 @@ func (b *BaseFs) AbsProjectContentDir(filename string) (string, string, error) { contentDirs := b.SourceFilesystems.Content.Dirs for i := len(contentDirs) - 1; i >= 0; i-- { meta := contentDirs[i].Meta() - if meta.Module == "project" { + if meta.IsProject { return filename, filepath.Join(meta.Filename, filename), nil } } @@ -645,6 +645,7 @@ func (b *sourceFilesystemsBuilder) createModFs( To: filename, ToBasedir: base, Module: md.Module.Path(), + IsProject: md.isMainProject, Meta: &hugofs.FileMeta{ Watch: md.Watch(), Weight: mountWeight, |