1use dioxus_lib::document::*;
4use dioxus_web::WebDocument;
5
6fn head_element_written_on_server() -> bool {
7 dioxus_fullstack_protocol::head_element_hydration_entry()
8 .get()
9 .ok()
10 .unwrap_or_default()
11}
12
13#[derive(Clone)]
15pub struct FullstackWebDocument;
16
17impl Document for FullstackWebDocument {
18 fn eval(&self, js: String) -> Eval {
19 WebDocument.eval(js)
20 }
21
22 fn set_title(&self, title: String) {
24 WebDocument.set_title(title);
25 }
26
27 fn create_meta(&self, props: MetaProps) {
29 WebDocument.create_meta(props);
30 }
31
32 fn create_script(&self, props: ScriptProps) {
34 WebDocument.create_script(props);
35 }
36
37 fn create_style(&self, props: StyleProps) {
39 WebDocument.create_style(props);
40 }
41
42 fn create_link(&self, props: LinkProps) {
44 WebDocument.create_link(props);
45 }
46
47 fn create_head_component(&self) -> bool {
48 !head_element_written_on_server()
49 }
50}