forked from SPC/spc-site
Fixing static gen after refactor
This commit is contained in:
parent
072655ac51
commit
f530b7605b
@ -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"
|
||||
}
|
||||
|
@ -186,7 +186,7 @@ context(PageBuilder) private fun HTML.spcHome() {
|
||||
header("major") {
|
||||
h3 {
|
||||
a(classes = "link") {
|
||||
href = resolvePageRef("consulting")
|
||||
href = resolvePageRef("consulting.index")
|
||||
+"""Consulting"""
|
||||
}
|
||||
}
|
||||
|
@ -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())
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -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<*>
|
||||
|
@ -50,6 +50,7 @@ interface SiteBuilder : ContextAware {
|
||||
|
||||
companion object {
|
||||
val INDEX_PAGE_TOKEN: NameToken = NameToken("index")
|
||||
val UP_PAGE_TOKEN: NameToken = NameToken("..")
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -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 {
|
||||
|
Loading…
Reference in New Issue
Block a user