aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--core/src/main/kotlin/renderers/DefaultRenderer.kt5
-rw-r--r--core/src/main/kotlin/renderers/HtmlRenderer.kt8
2 files changed, 8 insertions, 5 deletions
diff --git a/core/src/main/kotlin/renderers/DefaultRenderer.kt b/core/src/main/kotlin/renderers/DefaultRenderer.kt
index c5c12598..a92273ef 100644
--- a/core/src/main/kotlin/renderers/DefaultRenderer.kt
+++ b/core/src/main/kotlin/renderers/DefaultRenderer.kt
@@ -9,7 +9,7 @@ abstract class DefaultRenderer(val fileWriter: FileWriter, val locationProvider:
protected abstract fun buildNewLine(): String
protected abstract fun buildLink(text: String, address: String): String
protected abstract fun buildCode(code: String): String
- protected abstract fun buildNavigation(): String // TODO
+ protected abstract fun buildNavigation(page: PageNode): String
protected open fun buildText(text: String): String = text
protected open fun buildHeader(level: Int, content: List<ContentNode>, pageContext: PageNode): String = buildHeader(level, content.joinToString { it.build(pageContext) })
protected open fun buildGroup(children: List<ContentNode>, pageContext: PageNode): String = children.joinToString { it.build(pageContext) }
@@ -33,8 +33,7 @@ abstract class DefaultRenderer(val fileWriter: FileWriter, val locationProvider:
else -> ""
}
- protected open fun buildPageContent(page: PageNode): String =
- /*buildHeader(1, page.name) + */ page.content.joinToString("\n") { it.build(page) }
+ protected open fun buildPageContent(page: PageNode): String = buildNavigation(page) + page.content.joinToString("\n") { it.build(page) }
protected open fun renderPage(page: PageNode) = fileWriter.write(locationProvider.resolve(page), buildPageContent(page), "")
diff --git a/core/src/main/kotlin/renderers/HtmlRenderer.kt b/core/src/main/kotlin/renderers/HtmlRenderer.kt
index ce0e6b73..065b669a 100644
--- a/core/src/main/kotlin/renderers/HtmlRenderer.kt
+++ b/core/src/main/kotlin/renderers/HtmlRenderer.kt
@@ -23,8 +23,12 @@ open class HtmlRenderer(fileWriter: FileWriter, locationProvider: LocationProvid
override fun buildCode(code: String): String = "<code>$code</code>"
override fun buildText(text: String) = super.buildText(text).htmlEscape()
-
- override fun buildNavigation(): String = "" // TODO implement
+
+ override fun buildNavigation(page: PageNode): String {
+ fun buildNavigationWithContext(page: PageNode, context: PageNode): String =
+ page.parent?.let { buildNavigationWithContext(it, context) }.orEmpty() + "/" + buildLink(page.name, locationProvider.resolve(page, context))
+ return buildNavigationWithContext(page, page)
+ }
override fun buildGroup(children: List<ContentNode>, pageContext: PageNode): String =
children.find { it is ContentLink }?.build(pageContext) + "</td>\n" +