@@ -44,19 +44,23 @@ class StaticSiteContext(val root: File, sourceSets: Set[SourceSetWrapper], args:
4444
4545 lazy val mainPages : Seq [StaticPageNode ] = templates.map(templateToPage)
4646
47+ val docsPath = root.toPath.resolve(" docs" )
48+
4749 lazy val allPages : Seq [StaticPageNode ] = sideBarConfig.fold(mainPages){ sidebar =>
4850 def flattenPages (p : StaticPageNode ): Set [Path ] =
4951 Set (p.template.file.toPath) ++ p.getChildren.asScala.collect { case p : StaticPageNode => flattenPages(p) }.flatten
5052
5153 val mainFiles = mainPages.toSet.flatMap(flattenPages)
52- val docsPath = root.toPath.resolve( " docs " )
54+
5355 val allPaths =
5456 if ! Files .exists(docsPath) then Nil
5557 else Files .walk(docsPath, FileVisitOption .FOLLOW_LINKS ).iterator().asScala.toList
5658
5759 val orphanedFiles = allPaths.filterNot(mainFiles.contains).filter { p =>
5860 val name = p.getFileName.toString
59- name.endsWith(" .md" ) || name.endsWith(" .html" )
61+ def isSupported = name.endsWith(" .md" ) || name.endsWith(" .html" )
62+ def notIndex = name == " index.md" || name == " index.html"
63+ isSupported && notIndex
6064 }
6165
6266 val orphanedTemplates = orphanedFiles.flatMap(p => loadTemplate(p.toFile, isBlog = false ))
@@ -114,10 +118,14 @@ class StaticSiteContext(val root: File, sourceSets: Set[SourceSetWrapper], args:
114118 private def loadSidebarContent (entry : Sidebar ): LoadedTemplate = entry match
115119 case Sidebar .Page (title, url) =>
116120 val isBlog = title == " Blog"
117- val path = if isBlog then " blog" else url.stripSuffix(" .html" ) + " .md"
118- val file = root.toPath.resolve(path) // Add support for .html files!
119- val LoadedTemplate (template, children, tFile) = loadTemplate(file.toFile, isBlog).get // Add proper logging if file does not exisits
120- LoadedTemplate (template.copy(settings = template.settings + (" title" -> title)), children, tFile)
121+ val path = if isBlog then " blog" else
122+ if Files .exists(root.toPath.resolve(url)) then url
123+ else url.stripSuffix(" .html" ) + " .md"
124+
125+ val file = root.toPath.resolve(path).toFile
126+ val LoadedTemplate (template, children, _) = loadTemplate(file, isBlog).get // Add proper logging if file does not exisits
127+ LoadedTemplate (template.copy(settings = template.settings + (" title" -> title), file = file), children, file)
128+
121129 case Sidebar .Category (title, nested) =>
122130 // Add support for index.html/index.md files!
123131 val fakeFile = new File (root, title)
0 commit comments