Skip to content

Commit

Permalink
Fix nav generation with empty dirs
Browse files Browse the repository at this point in the history
  • Loading branch information
Ostrzyciel committed Nov 22, 2023
1 parent 5c42e7d commit e3acd99
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions src/main/scala/commands/NavGenCommand.scala
Original file line number Diff line number Diff line change
Expand Up @@ -132,10 +132,12 @@ object NavGenCommand extends Command:
private def listDir(rootDir: Path, dir: String, prettify: Boolean = true): Seq[YamlValue] =
rootDir.resolve(dir).toFile.listFiles()
.flatMap {
case f if f.isDirectory => Some(YamlMap(
if prettify then prettifyName(f.getName) else f.getName.stripSuffix(".md"),
YamlList(listDir(rootDir, (dir + "/" + f.getName).stripPrefix("/")))
))
case f if f.isDirectory =>
val list = YamlList(listDir(rootDir, (dir + "/" + f.getName).stripPrefix("/")))
if list.v.isEmpty then None else Some(YamlMap(
if prettify then prettifyName(f.getName) else f.getName.stripSuffix(".md"),
list
))
case f if f.isFile && f.getName.endsWith(".md") =>
val localPath = dir + "/" + f.getName
if f.getName == "index.md" then Some(YamlString(dir + "/index.md"))
Expand Down

0 comments on commit e3acd99

Please sign in to comment.