mirror of
https://github.com/gohugoio/hugo.git
synced 2024-11-07 20:30:36 -05:00
Merge pull request #38 from noahcampbell/workflow_dotfile
Workflow dotfile
This commit is contained in:
commit
7a51a8a5a3
4 changed files with 40 additions and 8 deletions
25
hugolib/content_directory_test.go
Normal file
25
hugolib/content_directory_test.go
Normal file
|
@ -0,0 +1,25 @@
|
|||
package hugolib
|
||||
|
||||
import (
|
||||
"testing"
|
||||
)
|
||||
|
||||
func TestIgnoreDotFiles(t *testing.T) {
|
||||
tests := []struct {
|
||||
path string
|
||||
ignore bool
|
||||
} {
|
||||
{"barfoo.md", false},
|
||||
{"foobar/barfoo.md", false},
|
||||
{"foobar/.barfoo.md", true},
|
||||
{".barfoo.md", true},
|
||||
{".md", true},
|
||||
{"", true},
|
||||
}
|
||||
|
||||
for _, test := range tests {
|
||||
if ignored := ignoreDotFile(test.path); test.ignore != ignored {
|
||||
t.Errorf("File not ignored. Expected: %t, got: %t", test.ignore, ignored)
|
||||
}
|
||||
}
|
||||
}
|
|
@ -47,5 +47,3 @@ func TestNewPageWithFilePath(t *testing.T) {
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -106,7 +106,9 @@ func (site *Site) Render() (err error) {
|
|||
site.timerStep("render shortcodes")
|
||||
site.AbsUrlify()
|
||||
site.timerStep("absolute URLify")
|
||||
site.RenderIndexes()
|
||||
if err = site.RenderIndexes(); err != nil {
|
||||
return
|
||||
}
|
||||
site.RenderIndexesIndexes()
|
||||
site.timerStep("render and write indexes")
|
||||
site.RenderLists()
|
||||
|
@ -199,12 +201,15 @@ func (s *Site) initialize() {
|
|||
site.Directories = append(site.Directories, path)
|
||||
return nil
|
||||
} else {
|
||||
if ignoreDotFile(path) {
|
||||
return nil
|
||||
}
|
||||
site.Files = append(site.Files, path)
|
||||
return nil
|
||||
}
|
||||
}
|
||||
|
||||
filepath.Walk(s.Config.GetAbsPath(s.Config.ContentDir), walker)
|
||||
filepath.Walk(s.absContentDir(), walker)
|
||||
|
||||
s.Info = SiteInfo{
|
||||
BaseUrl: template.URL(s.Config.BaseUrl),
|
||||
|
@ -216,6 +221,10 @@ func (s *Site) initialize() {
|
|||
s.Shortcodes = make(map[string]ShortcodeFunc)
|
||||
}
|
||||
|
||||
func ignoreDotFile(path string) bool {
|
||||
return filepath.Base(path)[0] == '.'
|
||||
}
|
||||
|
||||
func (s *Site) absLayoutDir() string {
|
||||
return s.Config.GetAbsPath(s.Config.LayoutDir)
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue