Skip to content

Scaladoc: Change default blog directory to 'blog' #14485

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Feb 15, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions scaladoc/src/dotty/tools/scaladoc/site/StaticSiteLoader.scala
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,7 @@ class StaticSiteLoader(val root: File, val args: Scaladoc.Args)(using StaticSite
def loadBlog(): Option[LoadedTemplate] = {
type Date = (String, String, String)
val rootPath = ctx.blogPath
val defaultDirectory = "blog"
if (!Files.exists(rootPath)) None
else {
val indexPageOpt = Seq(
Expand All @@ -131,7 +132,7 @@ class StaticSiteLoader(val root: File, val args: Scaladoc.Args)(using StaticSite
val indexTemplateOpt = indexPageOpt.map(p => loadTemplateFile(p.toFile))

val indexPage = indexTemplateOpt.getOrElse(emptyTemplate(rootPath.resolve("index.html").toFile, "Blog"))
val indexDest = ctx.docsPath.resolve("_blog").resolve("index.html")
val indexDest = ctx.docsPath.resolve(defaultDirectory).resolve("index.html")
val regex = raw"(\d*)-(\d*)-(\d*)-(.*)".r
def splitDateName(tf: TemplateFile): (Date, String) = tf.file.getName match
case regex(year, month, day, name) => ((year, month, day), name)
Expand All @@ -150,7 +151,7 @@ class StaticSiteLoader(val root: File, val args: Scaladoc.Args)(using StaticSite
.map { postFile =>
val templateFile = loadTemplateFile(postFile)
val ((year, month, day), name) = splitDateName(templateFile)
val destPath = ctx.docsPath.resolve("_blog").resolve(year).resolve(month).resolve(day).resolve(name)
val destPath = ctx.docsPath.resolve(defaultDirectory).resolve(year).resolve(month).resolve(day).resolve(name)
val date = dateFrom(templateFile, s"$year-$month-$day")
date -> LoadedTemplate(templateFile, List.empty, destPath.toFile)
}.sortBy(_._1).reverse.map(_._2)
Expand Down