Skip to content

Commit c38a214

Browse files
committed
Remove all parent directory elements (../) from navigation
1 parent f45e058 commit c38a214

File tree

1 file changed

+8
-4
lines changed

1 file changed

+8
-4
lines changed

buildSrc/src/main/kotlin/dokka-convention.gradle.kts

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -97,11 +97,15 @@ tasks.register("trimNavigationFiles") {
9797
val navigation = moduleDir.resolve("navigation.html").toFile()
9898
val doc = Jsoup.parse(navigation)
9999

100-
// Remove a single parent directory from all navigation links
100+
// Remove all parent directory elements from all navigation links
101101
doc.select("a[href^=../]").forEach { anchor ->
102-
val originalHref = anchor.attr("href")
103-
val updatedHref = originalHref.removePrefix("../")
104-
anchor.attr("href", updatedHref)
102+
var href = anchor.attr("href")
103+
104+
while (href.startsWith("../")) {
105+
href = href.removePrefix("../")
106+
}
107+
108+
anchor.attr("href", href)
105109
}
106110

107111
// Trim side menus

0 commit comments

Comments
 (0)