From 59ead0f26a3dd380dfbddfe10d5814c0ae5f9ba1 Mon Sep 17 00:00:00 2001 From: Daniel Fichtinger Date: Sat, 5 Apr 2025 17:17:30 -0400 Subject: [PATCH] treat config file as site root --- internal/util/path.go | 14 +++++++++----- test/.zona.yml | 0 2 files changed, 9 insertions(+), 5 deletions(-) create mode 100644 test/.zona.yml diff --git a/internal/util/path.go b/internal/util/path.go index 6c95cfc..1d9a740 100644 --- a/internal/util/path.go +++ b/internal/util/path.go @@ -22,17 +22,21 @@ func ChangeExtension(in string, outExt string) string { return strings.TrimSuffix(in, filepath.Ext(in)) + outExt } -// TODO: look for .zona.yml instead? +// find the root. check for a .zona.yml first, +// then check if it's cwd. func getRoot(path string) string { + marker := ".zona.yml" for { + // fmt.Printf("check for: %s\n", candidate) parent := filepath.Dir(path) - if parent == "." { - break + candidate := filepath.Join(parent, marker) + if FileExists(candidate) { + return parent + } else if parent == "." { + return path } path = parent } - // fmt.Println("getRoot: ", path) - return path } func ReplaceRoot(inPath, outRoot string) string { diff --git a/test/.zona.yml b/test/.zona.yml new file mode 100644 index 0000000..e69de29