diff --git a/example/pages/subdir/md_test.md b/example/pages/subdir/md_test.md index a848a32..0b474c3 100644 --- a/example/pages/subdir/md_test.md +++ b/example/pages/subdir/md_test.md @@ -1,3 +1,5 @@ # Hi there I'm in a subdirectory. + +And now I work. diff --git a/main.go b/main.go index e78325a..ab8495d 100644 --- a/main.go +++ b/main.go @@ -184,8 +184,6 @@ func WatchDir() { doit := time.NewTimer(wait_time) doit.Stop() - log.Println("WATCHING directory", config.Settings.Views) - go func() { for { select { @@ -206,9 +204,18 @@ func WatchDir() { } }() - err = watcher.Add(config.Settings.Views) - if err != nil { log.Fatal(err) } + err = filepath.WalkDir(config.Settings.Views, + func (path string, d fs.DirEntry, err error) error { + if d.IsDir() { + log.Println("WATCHING: ", path) + err = watcher.Add(path) + if err != nil { return Fail(err, "failed to watch %s", path) } + } + return nil + }) + + if err != nil { log.Fatalf("can't walk content") } <-make(chan struct{}) }