Ayfri
01/14/2024, 11:14 AMAppBlock.IndexBlock
depending on the route we're currently in. By just adding a property like route
or path
that would resolve this issue ! Is there any plan for that ? I don't like the current solution that is to replace some composables in the App code using rememberPageContext().route
. It seems so hacky for just a small detailDavid Herman
01/14/2024, 11:42 PMAyfri
01/14/2024, 11:46 PMapp { index { } }
block for defining the meta tags for my pages, but some needs to be different depending on the page (for example <link rel="canonical" href="something">
, there the href
should be the link to the current page, not the exact same for link for all the pages.
But currently AFAIK we can't do thatDavid Herman
01/14/2024, 11:51 PMAyfri
01/14/2024, 11:51 PMDavid Herman
01/14/2024, 11:52 PMapp { route("/a/b/c") { head.add { ... } } }
David Herman
01/14/2024, 11:52 PMDavid Herman
01/14/2024, 11:53 PMDavid Herman
01/14/2024, 11:53 PMDavid Herman
01/14/2024, 11:54 PMDavid Herman
01/14/2024, 11:55 PMAyfri
01/14/2024, 11:57 PMapp {
// (A way head.add {} could be simplified also)
head {
// here a property "route" is available, it is a String, or maybe an URL to allow more manipulations
link(href = route.ensureEndsWith("/"), rel = "canonical")
link(href = "$route.css", rel = "stylesheet")
}
}
Ayfri
01/14/2024, 11:59 PMDavid Herman
01/15/2024, 12:11 AMDavid Herman
01/15/2024, 12:11 AMDavid Herman
01/15/2024, 12:11 AMAyfri
01/15/2024, 12:12 AMDavid Herman
01/15/2024, 12:13 AMDavid Herman
01/15/2024, 12:13 AMDavid Herman
01/15/2024, 12:14 AMDavid Herman
01/15/2024, 12:14 AMRoland
04/04/2024, 6:25 PM// for now I solve it this way, but the result is that it only adds an additional description Tag
val description = document.createElement("meta").apply {
setAttribute("name","description")
setAttribute("content", "some description")
}
document.head?.appendChild(description?
// title works straight ahead
document.title = "my title"
Next question:
Is it possible to add more comprehensive links or completely custom tags in build.gradle.kts
For example this like it's possible in page:
val iconApple = document.createElement("link").apply {
setAttribute("rel", "apple-touch-icon")
setAttribute("sizes","180x180")
setAttribute("href", "/apple-touch-icon.png")
}
document.head?.appendChild(iconApple)
To be placed in this context:
kobweb.app.index.head.add {}
And lastly: Can we set the document language to something other than "en" ?David Herman
04/04/2024, 6:30 PMDavid Herman
04/04/2024, 6:30 PMRoland
04/05/2024, 6:00 AM<HTML lang="en">
I don't know if Google cares, but some SEO Check Tools complaining if the actual language used in text is different.David Herman
04/05/2024, 10:05 PM@App
block:
@App
@Composable
fun AppEntry(content: @Composable () -> Unit) {
document.documentElement!!.setAttribute("lang", "fr")
but I'll make sure you can set the language value in the next release of Kobweb (aiming to release in a few days)David Herman
04/05/2024, 10:14 PMkobweb {
app {
index {
lang.set("fr")
}
}
}
Sorry for missing your question the first time. Thanks for reporting this!