@@ -10,6 +10,8 @@ import org.jetbrains.dokka.pages.RootPageNode
10
10
import org .jetbrains .dokka .plugability .DokkaContext
11
11
12
12
import scala .collection .JavaConverters ._
13
+ import java .nio .file .Paths
14
+ import java .nio .file .Path
13
15
14
16
class StaticSiteLocationProviderFactory (private val ctx : DokkaContext ) extends LocationProviderFactory :
15
17
override def getLocationProvider (pageNode : RootPageNode ): LocationProvider =
@@ -24,11 +26,21 @@ class StaticSiteLocationProvider(ctx: DokkaContext, pageNode: RootPageNode)
24
26
val rawFilePath = context.root.toPath.relativize(page.template.file.toPath)
25
27
val pageName = page.template.file.getName
26
28
val dotIndex = pageName.lastIndexOf('.' )
27
- val newPath =
28
- if (dotIndex < 0 ) rawFilePath.resolve(" index" )
29
- else rawFilePath.resolveSibling(pageName.substring(0 , dotIndex))
30
29
31
- newPath.iterator.asScala.map(_.toString).toList.asJava
30
+ if (isBlogPostPath(rawFilePath)) {
31
+ val regex = raw " (\d*)-(\d*)-(\d*)-(.*)\..* " .r
32
+ val blogPostPath = pageName.toString match {
33
+ case regex(year, month, day, name) =>
34
+ rawFilePath.getParent.resolveSibling(Paths .get(year, month, day, name))
35
+ case _ => rawFilePath
36
+ }
37
+ blogPostPath.iterator.asScala.map(_.toString).toList.asJava
38
+ } else {
39
+ val newPath =
40
+ if (dotIndex < 0 ) rawFilePath.resolve(" index" )
41
+ else rawFilePath.resolveSibling(pageName.substring(0 , dotIndex))
42
+ newPath.iterator.asScala.map(_.toString).toList.asJava
43
+ }
32
44
}
33
45
34
46
case page : ContentPage if page.getDri.contains(docsDRI) =>
@@ -43,6 +55,8 @@ class StaticSiteLocationProvider(ctx: DokkaContext, pageNode: RootPageNode)
43
55
case _ =>
44
56
jpath
45
57
58
+ private def isBlogPostPath (path : Path ): Boolean = path.startsWith(Paths .get(" blog" ," _posts" ))
59
+
46
60
override val getPathsIndex : JMap [PageNode , JList [String ]] =
47
61
super .getPathsIndex.asScala.mapValuesInPlace(updatePageEntry).asJava
48
62
0 commit comments