forked from SPC/spc-site
Complete refactor to new routing API
This commit is contained in:
parent
218e76a2a8
commit
072655ac51
@ -46,10 +46,13 @@ internal class KtorSiteBuilder(
|
||||
|
||||
private fun resolveRef(baseUrl: String, ref: String) = if (baseUrl.isEmpty()) {
|
||||
ref
|
||||
} else if (ref.isEmpty()) {
|
||||
baseUrl
|
||||
} else {
|
||||
"${baseUrl.removeSuffix("/")}/$ref"
|
||||
}
|
||||
|
||||
|
||||
inner class KtorPageBuilder(
|
||||
val pageBaseUrl: String,
|
||||
override val meta: Meta = this@KtorSiteBuilder.meta,
|
||||
|
@ -5,10 +5,7 @@ import space.kscience.dataforge.data.*
|
||||
import space.kscience.dataforge.meta.Meta
|
||||
import space.kscience.dataforge.meta.get
|
||||
import space.kscience.dataforge.meta.string
|
||||
import space.kscience.dataforge.names.Name
|
||||
import space.kscience.dataforge.names.parseAsName
|
||||
import space.kscience.dataforge.names.plus
|
||||
import space.kscience.dataforge.names.startsWith
|
||||
import space.kscience.dataforge.names.*
|
||||
|
||||
internal fun Name.toWebPath() = tokens.joinToString(separator = "/")
|
||||
|
||||
@ -25,7 +22,7 @@ interface PageBuilder : ContextAware {
|
||||
|
||||
fun PageBuilder.resolvePageRef(pageName: String) = resolvePageRef(pageName.parseAsName())
|
||||
|
||||
val PageBuilder.homeRef get() = resolvePageRef(Name.EMPTY).removeSuffix("/")
|
||||
val PageBuilder.homeRef get() = resolvePageRef(SiteBuilder.INDEX_PAGE_TOKEN.asName())
|
||||
|
||||
/**
|
||||
* Resolve a Html builder by its full name
|
||||
|
@ -58,6 +58,8 @@ internal class StaticSiteBuilder(
|
||||
|
||||
private fun resolveRef(baseUrl: String, ref: String) = if (baseUrl.isEmpty()) {
|
||||
ref
|
||||
} else if (ref.isEmpty()) {
|
||||
baseUrl
|
||||
} else {
|
||||
"${baseUrl.removeSuffix("/")}/$ref"
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user