Skip to content

Commit a046777

Browse files
committed
Fix rendering of images on static pages
1 parent 1ad42c5 commit a046777

File tree

1 file changed

+10
-7
lines changed

1 file changed

+10
-7
lines changed

scala3doc/src/dotty/dokka/site/processors.scala

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ package site
33

44
import java.io.File
55
import java.nio.file.Files
6+
import java.nio.file.FileVisitOption
67

78
import org.jetbrains.dokka.base.renderers.html.{NavigationNode, NavigationPage}
89
import org.jetbrains.dokka.links.DRI
@@ -25,18 +26,20 @@ class SiteResourceManager(ctx: Option[StaticSiteContext]) extends BaseStaticSite
2526
}.toSet
2627

2728
override def transform(input: RootPageNode, ctx: StaticSiteContext): RootPageNode =
28-
val imgPath = ctx.root.toPath().resolve("images")
29+
val rootPath = ctx.root.toPath
30+
val imgPath = rootPath.resolve("images")
2931
val images =
3032
if !Files.exists(imgPath) then Nil
3133
else
32-
val stream = Files.walk(imgPath)filter(p => Files.isRegularFile(p) && p.getFileName().toString().endsWith(".svg"))
33-
stream.iterator().asScala.toList.map(_.toString)
34+
val allPaths = Files.walk(imgPath, FileVisitOption.FOLLOW_LINKS)
35+
val files = allPaths.filter(Files.isRegularFile(_)).iterator().asScala
36+
files.map(p => rootPath.relativize(p).toString).toList
3437

35-
val resources = listResources(input.getChildren.asScala.toList) ++ images
38+
val resources = images ++ listResources(input.getChildren.asScala.toList)
3639
val resourcePages = resources.map { path =>
37-
val content = Files.readAllLines(ctx.root.toPath.resolve(path)).asScala.mkString("\n")
38-
new RendererSpecificResourcePage(path, JList(), new RenderingStrategy.Write(content))
39-
}.toList
40+
val strategy = new RenderingStrategy.Copy(rootPath.resolve(path).toString)
41+
new RendererSpecificResourcePage(path, JList(), strategy)
42+
}
4043

4144
val modified = input.transformContentPagesTree {
4245
case it: StaticPageNode =>

0 commit comments

Comments
 (0)