@@ -44,19 +44,23 @@ class StaticSiteContext(val root: File, sourceSets: Set[SourceSetWrapper], args:
44
44
45
45
lazy val mainPages : Seq [StaticPageNode ] = templates.map(templateToPage)
46
46
47
+ val docsPath = root.toPath.resolve(" docs" )
48
+
47
49
lazy val allPages : Seq [StaticPageNode ] = sideBarConfig.fold(mainPages){ sidebar =>
48
50
def flattenPages (p : StaticPageNode ): Set [Path ] =
49
51
Set (p.template.file.toPath) ++ p.getChildren.asScala.collect { case p : StaticPageNode => flattenPages(p) }.flatten
50
52
51
53
val mainFiles = mainPages.toSet.flatMap(flattenPages)
52
- val docsPath = root.toPath.resolve( " docs " )
54
+
53
55
val allPaths =
54
56
if ! Files .exists(docsPath) then Nil
55
57
else Files .walk(docsPath, FileVisitOption .FOLLOW_LINKS ).iterator().asScala.toList
56
58
57
59
val orphanedFiles = allPaths.filterNot(mainFiles.contains).filter { p =>
58
60
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
60
64
}
61
65
62
66
val orphanedTemplates = orphanedFiles.flatMap(p => loadTemplate(p.toFile, isBlog = false ))
@@ -114,10 +118,14 @@ class StaticSiteContext(val root: File, sourceSets: Set[SourceSetWrapper], args:
114
118
private def loadSidebarContent (entry : Sidebar ): LoadedTemplate = entry match
115
119
case Sidebar .Page (title, url) =>
116
120
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
+
121
129
case Sidebar .Category (title, nested) =>
122
130
// Add support for index.html/index.md files!
123
131
val fakeFile = new File (root, title)
0 commit comments