#How do you change the title of a page inside lustre?
1 messages · Page 1 of 1 (latest)
lustre only owns the part of the dom you mount it on so this isn't really lustre's concern
you'd write an ffi function to set window.title and then you'd call that function in an effect from your update function
I see. Thanks!
@mystic forge thank you for the solution.
Just turned it into a blog post:
https://imadethissite.com/til/how-to-change-the-title-of-a-page-in-gleam
good post, just noting that the function set_window_title there is redundant as all it does is call the other function
there's a little more to it if you want to do it the correct way for lustre
specifically, i would do this:
import lustre/effect.{type Effect}
pub fn set_window_title(title: String) -> Effect(msg) {
use _ <- effect.from
do_set_window_title(title)
}
@external(javascript, "./set_window_title.js", "set_windowTitle")
pub fn do_set_window_title(title: String) -> Nil
and then in your update function you would do
fn update(model, msg) {
case msg {
Whatever -> #(model, set_window_title("wibble"))
}
}