summaryrefslogtreecommitdiffstats
path: root/hugofs
diff options
context:
space:
mode:
authorBjørn Erik Pedersen <bjorn.erik.pedersen@gmail.com>2024-02-05 14:54:02 +0100
committerBjørn Erik Pedersen <bjorn.erik.pedersen@gmail.com>2024-02-05 14:54:02 +0100
commit9df7b295bcfb59000f6ee675dfbbc53654f3d86c (patch)
tree2ff6fc5d081754120b6605d43ba6640ad94aa33f /hugofs
parentc37bf19c898035de1518c3f2ab4380f08817151f (diff)
Filter dot files etc. in i18n
Closes #11993
Diffstat (limited to 'hugofs')
-rw-r--r--hugofs/walk.go16
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)