diff --git a/src/main/kotlin/ru/mipt/spc/master.kt b/src/main/kotlin/ru/mipt/spc/master.kt index 8ab69d8..f873a52 100644 --- a/src/main/kotlin/ru/mipt/spc/master.kt +++ b/src/main/kotlin/ru/mipt/spc/master.kt @@ -327,7 +327,10 @@ internal fun SiteBuilder.spcMaster(dataPath: Path, prefix: Name = "magprog".asNa nav { ul { li { - a(classes = "spc-home", href = "/") { + a( + classes = "spc-home", + href = resolvePageRef(Name.of("..") + SiteBuilder.INDEX_PAGE_TOKEN) + ) { i("fa fa-home") { attributes["aria-hidden"] = "true" } diff --git a/src/main/kotlin/ru/mipt/spc/spcHome.kt b/src/main/kotlin/ru/mipt/spc/spcHome.kt index 96e4f5c..1aef1de 100644 --- a/src/main/kotlin/ru/mipt/spc/spcHome.kt +++ b/src/main/kotlin/ru/mipt/spc/spcHome.kt @@ -186,7 +186,7 @@ context(PageBuilder) private fun HTML.spcHome() { header("major") { h3 { a(classes = "link") { - href = resolvePageRef("consulting") + href = resolvePageRef("consulting.index") +"""Consulting""" } } diff --git a/src/main/kotlin/space/kscience/snark/KtorSiteBuilder.kt b/src/main/kotlin/space/kscience/snark/KtorSiteBuilder.kt index 215c579..7a6c766 100644 --- a/src/main/kotlin/space/kscience/snark/KtorSiteBuilder.kt +++ b/src/main/kotlin/space/kscience/snark/KtorSiteBuilder.kt @@ -63,9 +63,9 @@ internal class KtorSiteBuilder( override fun resolveRef(ref: String): String = resolveRef(pageBaseUrl, ref) override fun resolvePageRef(pageName: Name): String = if (pageName.endsWith(SiteBuilder.INDEX_PAGE_TOKEN)) { - resolveRef(pageName.cutLast().tokens.joinToString(separator = "/")) + resolveRef(pageName.cutLast().toWebPath()) } else { - resolveRef(pageName.tokens.joinToString(separator = "/")) + resolveRef(pageName.toWebPath()) } } diff --git a/src/main/kotlin/space/kscience/snark/PageBuilder.kt b/src/main/kotlin/space/kscience/snark/PageBuilder.kt index 9dd8d01..7acada4 100644 --- a/src/main/kotlin/space/kscience/snark/PageBuilder.kt +++ b/src/main/kotlin/space/kscience/snark/PageBuilder.kt @@ -7,7 +7,13 @@ import space.kscience.dataforge.meta.get import space.kscience.dataforge.meta.string import space.kscience.dataforge.names.* -internal fun Name.toWebPath() = tokens.joinToString(separator = "/") +internal fun Name.toWebPath() = tokens.joinToString(separator = "/"){ + if (it.hasIndex()) { + "${it.body}[${it.index}]" + } else { + it.body + } +} interface PageBuilder : ContextAware { val data: DataTree<*> diff --git a/src/main/kotlin/space/kscience/snark/SiteBuilder.kt b/src/main/kotlin/space/kscience/snark/SiteBuilder.kt index b1bcf5c..e6e96aa 100644 --- a/src/main/kotlin/space/kscience/snark/SiteBuilder.kt +++ b/src/main/kotlin/space/kscience/snark/SiteBuilder.kt @@ -50,6 +50,7 @@ interface SiteBuilder : ContextAware { companion object { val INDEX_PAGE_TOKEN: NameToken = NameToken("index") + val UP_PAGE_TOKEN: NameToken = NameToken("..") } } diff --git a/src/main/kotlin/space/kscience/snark/StaticSiteBuilder.kt b/src/main/kotlin/space/kscience/snark/StaticSiteBuilder.kt index 430d684..e4671e6 100644 --- a/src/main/kotlin/space/kscience/snark/StaticSiteBuilder.kt +++ b/src/main/kotlin/space/kscience/snark/StaticSiteBuilder.kt @@ -73,7 +73,7 @@ internal class StaticSiteBuilder( override fun resolveRef(ref: String): String = resolveRef(baseUrl, ref) override fun resolvePageRef(pageName: Name): String = resolveRef( - pageName.tokens.joinToString(separator = "/", postfix = ".html") + pageName.toWebPath() + ".html" ) } @@ -116,7 +116,7 @@ internal class StaticSiteBuilder( fun SnarkPlugin.static( outputPath: Path, data: DataTree<*> = DataTree.empty(), - siteUrl: String = outputPath.absolutePathString(), + siteUrl: String = outputPath.absolutePathString().replace("\\", "/"), block: SiteBuilder.() -> Unit, ) { contract {