@@ -5,6 +5,7 @@ import java.io.File
55import java .nio .file .Files
66import java .nio .file .{ Paths , Path }
77import scala .io ._
8+ import dotty .tools .scaladoc .site .BlogParser
89
910class StaticSiteLoader (val root : File , val args : Scaladoc .Args )(using StaticSiteContext , CompilerContext ):
1011 val ctx : StaticSiteContext = summon[StaticSiteContext ]
@@ -113,37 +114,13 @@ class StaticSiteLoader(val root: File, val args: Scaladoc.Args)(using StaticSite
113114 StaticSiteRoot (withBlog, mappings)
114115 }
115116
116- var hiddenBlog = false
117-
118- def readYml : (Option [Boolean ], Option [Boolean ], Option [Boolean ], String ) =
119- val ymlPath = root.toPath.resolve(" blog.yml" )
120- if (Files .exists(ymlPath)) then
121- val yamlContent = Source .fromFile(ymlPath.toString).getLines().mkString(" \n " )
122- val hidden = if (yamlContent.contains(" hidden: true" )) Some (true ) else None
123- val input = if (yamlContent.contains(" input:" )) Some (true ) else None
124- val output = if (yamlContent.contains(" output:" )) Some (true ) else None
125- (hidden, input, output, yamlContent)
126- else
127- (None , None , None , " " )
128-
129117 def loadBlog (): Option [LoadedTemplate ] = {
130- val (hidden, input, output, yamlContent) = readYml
131- val lines = yamlContent.split(" \n " )
132- val rootPath = input.collect {
133- case true =>
134- lines.collectFirst { case line if line.contains(" input:" ) => line.replaceFirst(" input:" , " " ).trim }
135- .map(ctx.resolveNewBlogPath)
136- .getOrElse(ctx.blogPath)
137- }.getOrElse(ctx.blogPath)
138- val defaultDirectory = output.collect {
139- case true =>
140- lines
141- .collectFirst { case line if line.contains(" output:" ) => line.replaceFirst(" output:" , " " ).trim }
142- .getOrElse(" blog" )
143- }.getOrElse(" blog" )
144- hidden.collect { case true => hiddenBlog = true }
118+ val blogConfig = BlogParser .readYml(root)
119+ val rootPath = Option (blogConfig.input).map(input => ctx.resolveNewBlogPath(input)).getOrElse(ctx.blogPath)
120+ val defaultDirectory = Option (blogConfig.output).getOrElse(" blog" )
121+
145122 type Date = (String , String , String )
146- if (! Files .exists(rootPath) || hiddenBlog ) None
123+ if (! Files .exists(rootPath) || blogConfig.hidden ) None
147124 else {
148125 val indexPageOpt = Seq (
149126 rootPath.resolve(" index.md" ),
0 commit comments