diff options
author | Bjørn Erik Pedersen <bjorn.erik.pedersen@gmail.com> | 2021-10-16 16:24:49 +0200 |
---|---|---|
committer | Bjørn Erik Pedersen <bjorn.erik.pedersen@gmail.com> | 2021-10-20 05:00:17 +0200 |
commit | 471ed91c60cd36645794925cb4892cc820eae626 (patch) | |
tree | b78ae6d931e7dd39ccd35a1ed3ff8440f9ef7900 /hugolib/filesystems | |
parent | 94a5bac5b29bbba1ca4809752fe3fd04a58547b6 (diff) |
hugofs: Add includeFiles and excludeFiles to mount configuration
Fixes #9042
Diffstat (limited to 'hugolib/filesystems')
-rw-r--r-- | hugolib/filesystems/basefs.go | 21 |
1 files changed, 17 insertions, 4 deletions
diff --git a/hugolib/filesystems/basefs.go b/hugolib/filesystems/basefs.go index 0a2c31240..cfbd295ba 100644 --- a/hugolib/filesystems/basefs.go +++ b/hugolib/filesystems/basefs.go @@ -25,6 +25,9 @@ import ( "sync" "github.com/gohugoio/hugo/htesting" + "github.com/gohugoio/hugo/hugofs/glob" + + "github.com/gohugoio/hugo/common/types" "github.com/gohugoio/hugo/common/loggers" "github.com/rogpeppe/go-internal/lockedfile" @@ -127,7 +130,8 @@ func (b *BaseFs) RelContentDir(filename string) string { return filename } -// AbsProjectContentDir tries to create a TODO1 +// AbsProjectContentDir tries to construct a filename below the most +// relevant content directory. func (b *BaseFs) AbsProjectContentDir(filename string) (string, string) { isAbs := filepath.IsAbs(filename) for _, dir := range b.SourceFilesystems.Content.Dirs { @@ -623,6 +627,14 @@ func (b *sourceFilesystemsBuilder) createModFs( mountWeight++ } + inclusionFilter, err := glob.NewFilenameFilter( + types.ToStringSlicePreserveString(mount.IncludeFiles), + types.ToStringSlicePreserveString(mount.ExcludeFiles), + ) + if err != nil { + return err + } + base, filename := absPathify(mount.Source) rm := hugofs.RootMapping{ @@ -631,9 +643,10 @@ func (b *sourceFilesystemsBuilder) createModFs( ToBasedir: base, Module: md.Module.Path(), Meta: &hugofs.FileMeta{ - Watch: md.Watch(), - Weight: mountWeight, - Classifier: files.ContentClassContent, + Watch: md.Watch(), + Weight: mountWeight, + Classifier: files.ContentClassContent, + InclusionFilter: inclusionFilter, }, } |