summaryrefslogtreecommitdiffstats
path: root/hugofs
diff options
context:
space:
mode:
authorBjørn Erik Pedersen <bjorn.erik.pedersen@gmail.com>2024-02-01 09:37:05 +0100
committerBjørn Erik Pedersen <bjorn.erik.pedersen@gmail.com>2024-02-01 19:42:55 +0100
commit4174a7866b75c6ae10827cc77dbae0676af8e5eb (patch)
tree90554344f1749dcdbcfe4587815643c35723b1c2 /hugofs
parent5dd06b4136aead1d4c8ef835f0670c32ae321152 (diff)
Fix disabled languages regression
Fixes #11959
Diffstat (limited to 'hugofs')
-rw-r--r--hugofs/component_fs.go29
1 files changed, 22 insertions, 7 deletions
diff --git a/hugofs/component_fs.go b/hugofs/component_fs.go
index 62d977ae8..e75e23f84 100644
--- a/hugofs/component_fs.go
+++ b/hugofs/component_fs.go
@@ -94,11 +94,15 @@ func (f *componentFsDir) ReadDir(count int) ([]iofs.DirEntry, error) {
fis = fis[:n]
+ n = 0
for _, fi := range fis {
s := path.Join(f.name, fi.Name())
- _ = f.fs.applyMeta(fi, s)
-
+ if _, ok := f.fs.applyMeta(fi, s); ok {
+ fis[n] = fi
+ n++
+ }
}
+ fis = fis[:n]
sort.Slice(fis, func(i, j int) bool {
fimi, fimj := fis[i].(FileMetaInfo), fis[j].(FileMetaInfo)
@@ -180,7 +184,8 @@ func (f *componentFsDir) Stat() (iofs.FileInfo, error) {
if err != nil {
return nil, err
}
- return f.fs.applyMeta(fi, f.name), nil
+ fim, _ := f.fs.applyMeta(fi, f.name)
+ return fim, nil
}
func (fs *componentFs) Stat(name string) (os.FileInfo, error) {
@@ -188,16 +193,26 @@ func (fs *componentFs) Stat(name string) (os.FileInfo, error) {
if err != nil {
return nil, err
}
- return fs.applyMeta(fi, name), nil
+ fim, _ := fs.applyMeta(fi, name)
+ return fim, nil
}
-func (fs *componentFs) applyMeta(fi FileNameIsDir, name string) FileMetaInfo {
+func (fs *componentFs) applyMeta(fi FileNameIsDir, name string) (FileMetaInfo, bool) {
if runtime.GOOS == "darwin" {
name = norm.NFC.String(name)
}
fim := fi.(FileMetaInfo)
meta := fim.Meta()
- meta.PathInfo = fs.opts.PathParser.Parse(fs.opts.Component, name)
+ pi := fs.opts.PathParser.Parse(fs.opts.Component, name)
+ if pi.Disabled() {
+ return fim, false
+ }
+ if meta.Lang != "" {
+ if isLangDisabled := fs.opts.PathParser.IsLangDisabled; isLangDisabled != nil && isLangDisabled(meta.Lang) {
+ return fim, false
+ }
+ }
+ meta.PathInfo = pi
if !fim.IsDir() {
if fileLang := meta.PathInfo.Lang(); fileLang != "" {
// A valid lang set in filename.
@@ -223,7 +238,7 @@ func (fs *componentFs) applyMeta(fi FileNameIsDir, name string) FileMetaInfo {
}
}
- return fim
+ return fim, true
}
func (f *componentFsDir) Readdir(count int) ([]os.FileInfo, error) {