@@ -8,6 +8,7 @@ import java.io.{ File => JFile, OutputStreamWriter, BufferedWriter, ByteArrayInp
8
8
import java .util .{ List => JList , Arrays }
9
9
import java .nio .file .Path
10
10
import java .nio .charset .StandardCharsets
11
+ import java .io .File .{ separator => sep }
11
12
12
13
import com .vladsch .flexmark .parser .ParserEmulationProfile
13
14
import com .vladsch .flexmark .parser .Parser
@@ -164,8 +165,8 @@ case class Site(
164
165
private def defaultParams (pageLocation : JFile , additionalDepth : Int = 0 ): DefaultParams = {
165
166
val pathFromRoot = stripRoot(pageLocation)
166
167
val baseUrl : String = {
167
- val rootLen = root.getAbsolutePath.split('/' ).length
168
- val assetLen = pageLocation.getAbsolutePath.split('/' ).length
168
+ val rootLen = root.getAbsolutePath.split(sep ).length
169
+ val assetLen = pageLocation.getAbsolutePath.split(sep ).length
169
170
" ../" * (assetLen - rootLen - 1 + additionalDepth) + " ."
170
171
}
171
172
@@ -195,12 +196,12 @@ case class Site(
195
196
// Suffix is index.html for packages and therefore the additional depth
196
197
// is increased by 1
197
198
val (suffix, offset) =
198
- if (e.kind == " package" ) (" / index.html" , - 1 )
199
+ if (e.kind == " package" ) (sep + " index.html" , - 1 )
199
200
else (" .html" , 0 )
200
201
201
- val target = mkdirs(fs.getPath(outDir.getAbsolutePath + " / api/ " + e.path.mkString(" / " ) + suffix))
202
+ val target = mkdirs(fs.getPath(outDir.getAbsolutePath + sep + " api" + sep + e.path.mkString(sep ) + suffix))
202
203
val params = defaultParams(target.toFile, - 1 ).withPosts(blogInfo).withEntity(Some (e)).toMap
203
- val page = new HtmlPage (" _layouts/ api-page.html" , layouts(" api-page" ).content, params, includes)
204
+ val page = new HtmlPage (" _layouts" + sep + " api-page.html" , layouts(" api-page" ).content, params, includes)
204
205
205
206
render(page).foreach { rendered =>
206
207
val source = new ByteArrayInputStream (rendered.getBytes(StandardCharsets .UTF_8 ))
@@ -217,9 +218,9 @@ case class Site(
217
218
}
218
219
219
220
// generate search page:
220
- val target = mkdirs(fs.getPath(outDir.getAbsolutePath + " / api/ search.html" ))
221
+ val target = mkdirs(fs.getPath(outDir.getAbsolutePath + sep + " api" + sep + " search.html" ))
221
222
val searchPageParams = defaultParams(target.toFile, - 1 ).withPosts(blogInfo).toMap
222
- val searchPage = new HtmlPage (" _layouts/ search.html" , layouts(" search" ).content, searchPageParams, includes)
223
+ val searchPage = new HtmlPage (" _layouts" + sep + " search.html" , layouts(" search" ).content, searchPageParams, includes)
223
224
render(searchPage).foreach { rendered =>
224
225
Files .copy(
225
226
new ByteArrayInputStream (rendered.getBytes(StandardCharsets .UTF_8 )),
@@ -230,7 +231,7 @@ case class Site(
230
231
}
231
232
232
233
/** Generate HTML files from markdown and .html sources */
233
- def generateHtmlFiles (outDir : JFile = new JFile (root.getAbsolutePath + " / _site" ))(implicit ctx : Context ): this .type =
234
+ def generateHtmlFiles (outDir : JFile = new JFile (root.getAbsolutePath + sep + " _site" ))(implicit ctx : Context ): this .type =
234
235
createOutput(outDir) {
235
236
compilableFiles.foreach { asset =>
236
237
val pathFromRoot = stripRoot(asset)
@@ -250,7 +251,7 @@ case class Site(
250
251
}
251
252
252
253
/** Generate blog from files in `blog/_posts` and output in `outDir` */
253
- def generateBlog (outDir : JFile = new JFile (root.getAbsolutePath + " / _site" ))(implicit ctx : Context ): this .type =
254
+ def generateBlog (outDir : JFile = new JFile (root.getAbsolutePath + sep + " _site" ))(implicit ctx : Context ): this .type =
254
255
createOutput(outDir) {
255
256
blogposts.foreach { file =>
256
257
val BlogPost .extract(year, month, day, name, ext) = file.getName
0 commit comments