Closed volnei closed 3 days ago
Hi @volnei! When using non-prefixed route mode, you will need to include the entire path for each route. If you want to prefix your Mithril routes with whatever path the page resolved on, you can access the current path with location.pathname
.
@barneycarroll thanks for your quick response!! So, I need to map and reference the /lang part in any of my routes and links?
Like this?
m.route.prefix("")
m.route(document.querySelector("#main"), "/en/", {
"/en/": layout(site),
"/en/login": layout(login)
}
Theres no way to make it more generic?
I think so. I thought for a moment it would be possible to put the language prefix as m.route.prefix('/en')
, but apparently not… 😕
Yes, I've tried this a minute ago, but not work too. Would not it be correct for mithril itself to be based on the href in base directive? React for example have a base path where we can configure this. Any change to make this topic a feature request?
Hi @volnei ,
i'm not sure what you are going to achieve, but can't you use just language placeholders and drop the whole "base href"? So
m.route(doc_root, "/", {
"/:lang/": ..
"/:lang/login": ...
})
Within your app, you will get vnode.attrs.lang as an interpolated value from ":lang" definition within the routes.
Closing due to age.
Mithril Version: 2.0.0-rc3
2.0.0-rc3
Im developing a multi language app using mithril where witch language have your directory. Eg.: /en/ /pt/ etc.
When running the application using Nginx and following http://localhost/pt/ the navigator is redirected to http://localhost.
The html file is:
And the mithril config is:
But in browser, the lang part for url is not respected and its automatically redirected to /.
Can anyone help me?
Thanks