summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authoruint <abhinav.prsai@gmail.com>2025-12-20 10:49:38 +0000
committeruint <abhinav.prsai@gmail.com>2025-12-20 10:49:38 +0000
commitb2394723c50699218929165f8a568caf1ffc6192 (patch)
treec7e3ac2e10c5b909d8f5e5a7a6b224a7873a9a14
parenta57d3fbf61708aba67b08767bc35bcde77182efd (diff)
fix directories with only index.md being skipped
-rw-r--r--kew.go13
1 files changed, 7 insertions, 6 deletions
diff --git a/kew.go b/kew.go
index 208136d..c6a5fd6 100644
--- a/kew.go
+++ b/kew.go
@@ -31,11 +31,6 @@ func build_nav(dir string, root string) (NavNode, bool) {
if e.IsDir() {
child, ok := build_nav(full, root)
if ok {
- _, err := os.Stat(filepath.Join(full, "index.md"))
- if err == nil {
- rel_dir, _ := filepath.Rel(root, full)
- child.Path = rel_dir + "/index.html"
- }
node.Children = append(node.Children, child)
}
continue
@@ -43,6 +38,12 @@ func build_nav(dir string, root string) (NavNode, bool) {
if strings.HasSuffix(e.Name(), ".md") {
if e.Name() == "index.md" {
+ rel_dir, _ := filepath.Rel(root, dir)
+ if rel_dir == "." {
+ node.Path = "index.html"
+ } else {
+ node.Path = rel_dir + "/index.html"
+ }
continue
}
rel, _ := filepath.Rel(root, full)
@@ -55,7 +56,7 @@ func build_nav(dir string, root string) (NavNode, bool) {
}
}
- if len(node.Files) == 0 && len(node.Children) == 0 {
+ if len(node.Files) == 0 && len(node.Children) == 0 && node.Path == "" {
return node, false
}