diff --git a/sandwitchboard.go b/sandwitchboard.go index 14d1125..890b067 100644 --- a/sandwitchboard.go +++ b/sandwitchboard.go @@ -170,6 +170,10 @@ func main() { } } +func isExcluded(name string) bool { + return strings.HasPrefix(strings.ToUpper(name), "README") +} + func (g *generateCmd) Run() error { fi, err := os.Stat(g.Output) if err != nil && !os.IsNotExist(err) { @@ -189,7 +193,22 @@ func (g *generateCmd) Run() error { walkErr := filepath.WalkDir(g.Path, func(path string, d fs.DirEntry, err error) error { slog.Debug("Walking through file", "path", path) - relpath := filepath.Join(strings.Split(path, "/")[1:]...) + + if isExcluded(d.Name()) { + slog.Debug("Excluded file, skipping", "name", d.Name()) + return nil + } + + apath, err := filepath.Abs(path) + if err != nil { + return fmt.Errorf("cannot get the abs path for %q: %w", path, err) + } + + relpath, err := filepath.Rel(g.Path, apath) + if err != nil { + return fmt.Errorf("cannot get relative path for %s: %w", apath, err) + } + ext := filepath.Ext(d.Name()) recipeName := strings.TrimSuffix(d.Name(), ext) if d.IsDir() { diff --git a/templates/style.css b/templates/style.css index fe94148..cd419a2 100644 --- a/templates/style.css +++ b/templates/style.css @@ -2,3 +2,15 @@ body { background-color: lightgrey; font-family: monospace; } + +.ingredient { + color: green; +} + +.cookware { + color: red; +} + +.timer { + color: blue; +}