fix directories with only index.md being skipped
This commit is contained in:
parent
a57d3fbf61
commit
b2394723c5
1 changed files with 7 additions and 6 deletions
13
kew.go
13
kew.go
|
|
@ -31,11 +31,6 @@ func build_nav(dir string, root string) (NavNode, bool) {
|
||||||
if e.IsDir() {
|
if e.IsDir() {
|
||||||
child, ok := build_nav(full, root)
|
child, ok := build_nav(full, root)
|
||||||
if ok {
|
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)
|
node.Children = append(node.Children, child)
|
||||||
}
|
}
|
||||||
continue
|
continue
|
||||||
|
|
@ -43,6 +38,12 @@ func build_nav(dir string, root string) (NavNode, bool) {
|
||||||
|
|
||||||
if strings.HasSuffix(e.Name(), ".md") {
|
if strings.HasSuffix(e.Name(), ".md") {
|
||||||
if e.Name() == "index.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
|
continue
|
||||||
}
|
}
|
||||||
rel, _ := filepath.Rel(root, full)
|
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
|
return node, false
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue