mirror of
https://github.com/gohugoio/hugo.git
synced 2024-11-21 20:46:30 -05:00
parent
c37bf19c89
commit
9df7b295bc
5 changed files with 38 additions and 14 deletions
|
@ -55,6 +55,7 @@ type WalkwayConfig struct {
|
||||||
// One or both of these may be pre-set.
|
// One or both of these may be pre-set.
|
||||||
Info FileMetaInfo // The start info.
|
Info FileMetaInfo // The start info.
|
||||||
DirEntries []FileMetaInfo // The start info's dir entries.
|
DirEntries []FileMetaInfo // The start info's dir entries.
|
||||||
|
IgnoreFile func(filename string) bool // Optional
|
||||||
|
|
||||||
// Will be called in order.
|
// Will be called in order.
|
||||||
HookPre WalkHook // Optional.
|
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 {
|
if w.cfg.HookPre != nil {
|
||||||
var err error
|
var err error
|
||||||
dirEntries, err = w.cfg.HookPre(info, path, dirEntries)
|
dirEntries, err = w.cfg.HookPre(info, path, dirEntries)
|
||||||
|
|
|
@ -474,6 +474,7 @@ func (h *HugoSites) loadData() error {
|
||||||
w := hugofs.NewWalkway(
|
w := hugofs.NewWalkway(
|
||||||
hugofs.WalkwayConfig{
|
hugofs.WalkwayConfig{
|
||||||
Fs: h.PathSpec.BaseFs.Data.Fs,
|
Fs: h.PathSpec.BaseFs.Data.Fs,
|
||||||
|
IgnoreFile: h.SourceSpec.IgnoreFile,
|
||||||
WalkFn: func(path string, fi hugofs.FileMetaInfo) error {
|
WalkFn: func(path string, fi hugofs.FileMetaInfo) error {
|
||||||
if fi.IsDir() {
|
if fi.IsDir() {
|
||||||
return nil
|
return nil
|
||||||
|
|
|
@ -135,3 +135,14 @@ FormatNumberCustom: 12,345.68
|
||||||
NumFmt: -98,765.43
|
NumFmt: -98,765.43
|
||||||
`)
|
`)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Issue 11993.
|
||||||
|
func TestI18nDotFile(t *testing.T) {
|
||||||
|
files := `
|
||||||
|
-- hugo.toml --{}
|
||||||
|
baseURL = "https://example.com"
|
||||||
|
-- i18n/.keep --
|
||||||
|
-- data/.keep --
|
||||||
|
`
|
||||||
|
Test(t, files)
|
||||||
|
}
|
||||||
|
|
|
@ -249,9 +249,6 @@ func (c *pagesCollector) collectDir(dirPath *paths.Path, isDir bool, inFilter fu
|
||||||
|
|
||||||
func (c *pagesCollector) collectDirDir(path string, root hugofs.FileMetaInfo, inFilter func(fim hugofs.FileMetaInfo) bool) error {
|
func (c *pagesCollector) collectDirDir(path string, root hugofs.FileMetaInfo, inFilter func(fim hugofs.FileMetaInfo) bool) error {
|
||||||
filter := func(fim hugofs.FileMetaInfo) bool {
|
filter := func(fim hugofs.FileMetaInfo) bool {
|
||||||
if c.sp.IgnoreFile(fim.Meta().Filename) {
|
|
||||||
return false
|
|
||||||
}
|
|
||||||
if inFilter != nil {
|
if inFilter != nil {
|
||||||
return inFilter(fim)
|
return inFilter(fim)
|
||||||
}
|
}
|
||||||
|
@ -334,6 +331,7 @@ func (c *pagesCollector) collectDirDir(path string, root hugofs.FileMetaInfo, in
|
||||||
Root: path,
|
Root: path,
|
||||||
Info: root,
|
Info: root,
|
||||||
Fs: c.fs,
|
Fs: c.fs,
|
||||||
|
IgnoreFile: c.h.SourceSpec.IgnoreFile,
|
||||||
HookPre: preHook,
|
HookPre: preHook,
|
||||||
HookPost: postHook,
|
HookPost: postHook,
|
||||||
WalkFn: wfn,
|
WalkFn: wfn,
|
||||||
|
@ -371,6 +369,7 @@ func (c *pagesCollector) handleBundleLeaf(dir, bundle hugofs.FileMetaInfo, inPat
|
||||||
Logger: c.logger,
|
Logger: c.logger,
|
||||||
Info: dir,
|
Info: dir,
|
||||||
DirEntries: readdir,
|
DirEntries: readdir,
|
||||||
|
IgnoreFile: c.h.SourceSpec.IgnoreFile,
|
||||||
WalkFn: walk,
|
WalkFn: walk,
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|
|
@ -60,6 +60,7 @@ func (tp *TranslationProvider) NewResource(dst *deps.Deps) error {
|
||||||
w := hugofs.NewWalkway(
|
w := hugofs.NewWalkway(
|
||||||
hugofs.WalkwayConfig{
|
hugofs.WalkwayConfig{
|
||||||
Fs: dst.BaseFs.I18n.Fs,
|
Fs: dst.BaseFs.I18n.Fs,
|
||||||
|
IgnoreFile: dst.SourceSpec.IgnoreFile,
|
||||||
WalkFn: func(path string, info hugofs.FileMetaInfo) error {
|
WalkFn: func(path string, info hugofs.FileMetaInfo) error {
|
||||||
if info.IsDir() {
|
if info.IsDir() {
|
||||||
return nil
|
return nil
|
||||||
|
|
Loading…
Reference in a new issue