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 /hugofs/fileinfo.go | |
parent | 94a5bac5b29bbba1ca4809752fe3fd04a58547b6 (diff) |
hugofs: Add includeFiles and excludeFiles to mount configuration
Fixes #9042
Diffstat (limited to 'hugofs/fileinfo.go')
-rw-r--r-- | hugofs/fileinfo.go | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/hugofs/fileinfo.go b/hugofs/fileinfo.go index fcf35d956..ea6ac4fd3 100644 --- a/hugofs/fileinfo.go +++ b/hugofs/fileinfo.go @@ -23,6 +23,8 @@ import ( "strings" "time" + "github.com/gohugoio/hugo/hugofs/glob" + "github.com/gohugoio/hugo/hugofs/files" "golang.org/x/text/unicode/norm" @@ -76,6 +78,9 @@ type FileMeta struct { Fs afero.Fs OpenFunc func() (afero.File, error) JoinStatFunc func(name string) (FileMetaInfo, error) + + // Include only files or directories that match. + InclusionFilter *glob.FilenameFilter } func (m *FileMeta) Copy() *FileMeta { @@ -95,10 +100,17 @@ func (m *FileMeta) Merge(from *FileMeta) { for i := 0; i < dstv.NumField(); i++ { v := dstv.Field(i) + if !v.CanSet() { + continue + } if !hreflect.IsTruthfulValue(v) { v.Set(srcv.Field(i)) } } + + if m.InclusionFilter == nil { + m.InclusionFilter = from.InclusionFilter + } } func (f *FileMeta) Open() (afero.File, error) { |