dioxus_fullstack_core/
document.rs1use dioxus_document::*;
4
5fn head_element_written_on_server() -> bool {
6 crate::transport::head_element_hydration_entry()
7 .get()
8 .ok()
9 .unwrap_or_default()
10}
11
12#[derive(Clone)]
14pub struct FullstackWebDocument<D> {
15 document: D,
16}
17
18impl<D> From<D> for FullstackWebDocument<D> {
19 fn from(document: D) -> Self {
20 Self { document }
21 }
22}
23
24impl<D: Document> Document for FullstackWebDocument<D> {
25 fn eval(&self, js: String) -> Eval {
26 self.document.eval(js)
27 }
28
29 fn set_title(&self, title: String) {
31 self.document.set_title(title);
32 }
33
34 fn create_meta(&self, props: MetaProps) {
36 self.document.create_meta(props);
37 }
38
39 fn create_script(&self, props: ScriptProps) {
41 self.document.create_script(props);
42 }
43
44 fn create_style(&self, props: StyleProps) {
46 self.document.create_style(props);
47 }
48
49 fn create_link(&self, props: LinkProps) {
51 self.document.create_link(props);
52 }
53
54 fn create_head_component(&self) -> bool {
55 !head_element_written_on_server()
56 }
57}