diff options
author | Bjørn Erik Pedersen <[email protected]> | 2024-02-05 14:54:02 +0100 |
---|---|---|
committer | Bjørn Erik Pedersen <[email protected]> | 2024-02-05 14:54:02 +0100 |
commit | 9df7b295bcfb59000f6ee675dfbbc53654f3d86c (patch) | |
tree | 2ff6fc5d081754120b6605d43ba6640ad94aa33f /hugofs | |
parent | c37bf19c898035de1518c3f2ab4380f08817151f (diff) | |
download | hugo-9df7b295bcfb59000f6ee675dfbbc53654f3d86c.tar.gz hugo-9df7b295bcfb59000f6ee675dfbbc53654f3d86c.zip |
Filter dot files etc. in i18n
Closes #11993
Diffstat (limited to 'hugofs')
-rw-r--r-- | hugofs/walk.go | 16 |
1 files changed, 14 insertions, 2 deletions
diff --git a/hugofs/walk.go b/hugofs/walk.go index 18667a5fc..391f70a65 100644 --- a/hugofs/walk.go +++ b/hugofs/walk.go @@ -53,8 +53,9 @@ type WalkwayConfig struct { Logger loggers.Logger // One or both of these may be pre-set. - Info FileMetaInfo // The start info. - DirEntries []FileMetaInfo // The start info's dir entries. + Info FileMetaInfo // The start info. + DirEntries []FileMetaInfo // The start info's dir entries. + IgnoreFile func(filename string) bool // Optional // Will be called in order. HookPre WalkHook // Optional. @@ -172,6 +173,17 @@ func (w *Walkway) walk(path string, info FileMetaInfo, dirEntries []FileMetaInfo } + if w.cfg.IgnoreFile != nil { + n := 0 + for _, fi := range dirEntries { + if !w.cfg.IgnoreFile(fi.Meta().Filename) { + dirEntries[n] = fi + n++ + } + } + dirEntries = dirEntries[:n] + } + if w.cfg.HookPre != nil { var err error dirEntries, err = w.cfg.HookPre(info, path, dirEntries) |