diff --git a/cli/htmgo/tasks/css/css.go b/cli/htmgo/tasks/css/css.go index 0bdaf58..1c07ec2 100644 --- a/cli/htmgo/tasks/css/css.go +++ b/cli/htmgo/tasks/css/css.go @@ -12,7 +12,7 @@ import ( ) func IsTailwindEnabled() bool { - return dirutil.HasFileFromRoot("tailwind.config.js") + return dirutil.GetConfig().Tailwind && dirutil.HasFileFromRoot("tailwind.config.js") } func Setup() bool { diff --git a/cli/htmgo/watcher.go b/cli/htmgo/watcher.go index 5af47b7..4838d14 100644 --- a/cli/htmgo/watcher.go +++ b/cli/htmgo/watcher.go @@ -1,7 +1,6 @@ package main import ( - "fmt" "github.com/fsnotify/fsnotify" "github.com/google/uuid" "github.com/maddalax/htmgo/cli/htmgo/internal" @@ -36,8 +35,6 @@ func startWatcher(cb func(version string, file []*fsnotify.Event)) { for { select { case event, ok := <-watcher.Events: - slog.Debug("event:", slog.String("name", event.Name), slog.String("op", event.Op.String())) - if !ok { return } @@ -69,23 +66,25 @@ func startWatcher(cb func(version string, file []*fsnotify.Event)) { } } - if dirutil.IsGlobMatch(event.Name, config.WatchFiles, config.WatchIgnore) { - if event.Has(fsnotify.Write) || event.Has(fsnotify.Remove) || event.Has(fsnotify.Rename) { - events = append(events, &event) - debouncer.Do(func() { - seen := make(map[string]bool) - dedupe := make([]*fsnotify.Event, 0) - for _, e := range events { - if _, ok := seen[e.Name]; !ok { - seen[e.Name] = true - dedupe = append(dedupe, e) - } - } - cb(uuid.NewString()[0:6], dedupe) - events = make([]*fsnotify.Event, 0) - }) + if event.Has(fsnotify.Write) || event.Has(fsnotify.Remove) || event.Has(fsnotify.Rename) { + if !dirutil.IsGlobMatch(event.Name, config.WatchFiles, config.WatchIgnore) { + continue } + events = append(events, &event) + debouncer.Do(func() { + seen := make(map[string]bool) + dedupe := make([]*fsnotify.Event, 0) + for _, e := range events { + if _, ok := seen[e.Name]; !ok { + seen[e.Name] = true + dedupe = append(dedupe, e) + } + } + cb(uuid.NewString()[0:6], dedupe) + events = make([]*fsnotify.Event, 0) + }) } + case err, ok := <-watcher.Errors: if !ok { return @@ -105,15 +104,6 @@ func startWatcher(cb func(version string, file []*fsnotify.Event)) { watcher.Add(assetPath) } - go func() { - for { - time.Sleep(time.Second * 5) - files := watcher.WatchList() - count := len(files) - fmt.Printf("Watching %d dirs\n", count) - } - }() - // Walk through the root directory and add all subdirectories to the watcher err = filepath.Walk(rootDir, func(path string, info os.FileInfo, err error) error { if err != nil { diff --git a/framework/config/default.yml b/framework/config/default.yml deleted file mode 100644 index bd7be9a..0000000 --- a/framework/config/default.yml +++ /dev/null @@ -1 +0,0 @@ -tailwind: true diff --git a/framework/config/project.go b/framework/config/project.go index a3cd1d2..688241d 100644 --- a/framework/config/project.go +++ b/framework/config/project.go @@ -19,7 +19,7 @@ func DefaultProjectConfig() *ProjectConfig { "node_modules", ".git", ".idea", "assets/dist", }, WatchFiles: []string{ - "**/*.go", "**/*.html", "**/*.css", "**/*.js", "**/*.json", "**/*.yaml", "**/*.yml", + "**/*.go", "**/*.html", "**/*.css", "**/*.js", "**/*.json", "**/*.yaml", "**/*.yml", "**/*.md", }, } } diff --git a/htmgo-site/htmgo.yml b/htmgo-site/htmgo.yml index 67500d7..d60d2ff 100644 --- a/htmgo-site/htmgo.yml +++ b/htmgo-site/htmgo.yml @@ -1,5 +1,10 @@ +# htmgo configuration + +# if tailwindcss is enabled, htmgo will automatically compile your tailwind and output it to assets/dist tailwind: true -# which directories to ignore when watching for changes, supports glob patterns + +# which directories to ignore when watching for changes, supports glob patterns through https://github.com/bmatcuk/doublestar watch_ignore: [".git", "node_modules", "dist/*"] -# files to watch for changes that are not included by default, supports glob patterns -watch_files: ["**/*.go", "**/*.css"] + +# files to watch for changes, supports glob patterns through https://github.com/bmatcuk/doublestar +watch_files: ["**/*.go", "**/*.css", "**/*.md"] diff --git a/htmgo-site/pages/base/root.go b/htmgo-site/pages/base/root.go index c15900b..b110caa 100644 --- a/htmgo-site/pages/base/root.go +++ b/htmgo-site/pages/base/root.go @@ -45,7 +45,8 @@ func PageWithNav(ctx *h.RequestContext, children ...h.Ren) *h.Element { return RootPage(ctx, h.Fragment( partials.NavBar(ctx, partials.NavBarProps{ - Expanded: false, + Expanded: false, + ShowPreRelease: true, }), h.Div( children...,