aboutsummaryrefslogtreecommitdiff
path: root/plugins/base/src/main/kotlin
diff options
context:
space:
mode:
authorFilip Zybała <fzybala@virtuslab.com>2020-06-03 14:43:27 +0200
committerPaweł Marks <Kordyjan@users.noreply.github.com>2020-06-03 15:18:58 +0200
commit7674ce23f132f727b71545ad3aa62be5059613d6 (patch)
tree687e6ad8aff39e27a1bec6c195089db54daad052 /plugins/base/src/main/kotlin
parentcb705ba0f457b6e0eb02337d9444d6f0ad1e67a3 (diff)
downloaddokka-7674ce23f132f727b71545ad3aa62be5059613d6.tar.gz
dokka-7674ce23f132f727b71545ad3aa62be5059613d6.tar.bz2
dokka-7674ce23f132f727b71545ad3aa62be5059613d6.zip
Fixed problem with linking absolute links as relative
Diffstat (limited to 'plugins/base/src/main/kotlin')
-rw-r--r--plugins/base/src/main/kotlin/renderers/html/HtmlRenderer.kt7
1 files changed, 5 insertions, 2 deletions
diff --git a/plugins/base/src/main/kotlin/renderers/html/HtmlRenderer.kt b/plugins/base/src/main/kotlin/renderers/html/HtmlRenderer.kt
index 79e49d53..e73a36b2 100644
--- a/plugins/base/src/main/kotlin/renderers/html/HtmlRenderer.kt
+++ b/plugins/base/src/main/kotlin/renderers/html/HtmlRenderer.kt
@@ -14,6 +14,7 @@ import org.jetbrains.dokka.plugability.plugin
import org.jetbrains.dokka.plugability.query
import org.jetbrains.dokka.plugability.querySingle
import java.io.File
+import java.net.URI
open class HtmlRenderer(
context: DokkaContext
@@ -493,6 +494,8 @@ open class HtmlRenderer(
}
}
+ private fun resolveLink(link: String, page: PageNode) : String = if (URI(link).isAbsolute) link else page.root(link)
+
open fun buildHtml(page: PageNode, resources: List<String>, content: FlowContent.() -> Unit) =
createHTML().html {
head {
@@ -500,9 +503,9 @@ open class HtmlRenderer(
title(page.name)
with(resources) {
filter { it.substringBefore('?').substringAfterLast('.') == "css" }
- .forEach { link(rel = LinkRel.stylesheet, href = page.root(it)) }
+ .forEach { link(rel = LinkRel.stylesheet, href = resolveLink(it,page)) }
filter { it.substringBefore('?').substringAfterLast('.') == "js" }
- .forEach { script(type = ScriptType.textJavaScript, src = page.root(it)) { async = true } }
+ .forEach { script(type = ScriptType.textJavaScript, src = resolveLink(it,page)) { async = true } }
}
script { unsafe { +"""var pathToRoot = "${locationProvider.resolveRoot(page)}";""" } }
}