@@ -17,7 +17,6 @@ import org.jetbrains.dokka.model.DisplaySourceSet
17
17
import scala .collection .JavaConverters ._
18
18
19
19
class StaticSiteContext (val root : File , sourceSets : Set [SourceSetWrapper ]):
20
- val docsFile = new File (root, " docs" )
21
20
22
21
def indexPage (): Option [StaticPageNode ] =
23
22
val files = List (new File (root, " index.html" ), new File (root, " index.md" )).filter { _.exists() }
@@ -35,10 +34,12 @@ class StaticSiteContext(val root: File, sourceSets: Set[SourceSetWrapper]):
35
34
file.getName.endsWith(" .html" )
36
35
37
36
38
- private def loadTemplate (from : File ): Option [LoadedTemplate ] =
37
+ private def loadTemplate (from : File , isBlog : Boolean = false ): Option [LoadedTemplate ] =
39
38
if (! isValidTemplate(from)) None else
40
39
try
41
- val (indexes, children) = Option (from.listFiles()).toSeq.flatten.flatMap(loadTemplate).partition(_.templateFile.isIndexPage())
40
+ val topLevelFiles = if isBlog then Seq (from, new File (from, " _posts" )) else Seq (from)
41
+ val allFiles = topLevelFiles.filter(_.isDirectory).flatMap(_.listFiles())
42
+ val (indexes, children) = allFiles.flatMap(loadTemplate(_)).partition(_.templateFile.isIndexPage())
42
43
if (indexes.size > 1 )
43
44
println(s " ERROR: Multiple index pages for $from found in ${indexes.map(_.file)}" ) // TODO (#14): provide proper error handling
44
45
@@ -67,8 +68,12 @@ class StaticSiteContext(val root: File, sourceSets: Set[SourceSetWrapper]):
67
68
new PropertyContainer (JMap ())
68
69
)
69
70
70
- def loadFiles (files : List [File ], customChildren : List [PageNode ] = Nil ): List [StaticPageNode ] =
71
- val all = files.flatMap(loadTemplate)
71
+ def loadAllFiles () =
72
+ def dir (name : String )= List (new File (root, name)).filter(_.isDirectory)
73
+ loadFiles(dir(" docs" ).flatMap(_.listFiles())) ++ loadFiles(dir(" blog" ), isBlog = true )
74
+
75
+ def loadFiles (files : List [File ], isBlog : Boolean = false ): List [StaticPageNode ] =
76
+ val all = files.flatMap(loadTemplate(_, isBlog))
72
77
def flatten (it : LoadedTemplate ): List [String ] =
73
78
List (it.relativePath(root)) ++ it.children.flatMap(flatten)
74
79
@@ -92,7 +97,7 @@ class StaticSiteContext(val root: File, sourceSets: Set[SourceSetWrapper]):
92
97
content,
93
98
JSet (dri),
94
99
JList (),
95
- (myTemplate.children.map(templateToPage) ++ customChildren ).asJava
100
+ (myTemplate.children.map(templateToPage)).asJava
96
101
)
97
102
98
103
all.map(templateToPage)
0 commit comments