dioxus_document/elements/
meta.rs1use super::*;
2use crate::document;
3use dioxus_html as dioxus_elements;
4
5#[non_exhaustive]
6#[derive(Clone, Props, PartialEq)]
8pub struct MetaProps {
9 pub property: Option<String>,
10 pub name: Option<String>,
11 pub charset: Option<String>,
12 pub http_equiv: Option<String>,
13 pub content: Option<String>,
14 #[props(extends = meta, extends = GlobalAttributes)]
15 pub additional_attributes: Vec<Attribute>,
16}
17
18impl MetaProps {
19 pub fn attributes(&self) -> Vec<(&'static str, String)> {
21 let mut attributes = Vec::new();
22 extend_attributes(&mut attributes, &self.additional_attributes);
23 if let Some(property) = &self.property {
24 attributes.push(("property", property.clone()));
25 }
26 if let Some(name) = &self.name {
27 attributes.push(("name", name.clone()));
28 }
29 if let Some(charset) = &self.charset {
30 attributes.push(("charset", charset.clone()));
31 }
32 if let Some(http_equiv) = &self.http_equiv {
33 attributes.push(("http-equiv", http_equiv.clone()));
34 }
35 if let Some(content) = &self.content {
36 attributes.push(("content", content.clone()));
37 }
38 attributes
39 }
40}
41
42#[component]
66#[doc(alias = "<meta>")]
67pub fn Meta(props: MetaProps) -> Element {
68 use_update_warning(&props, "Meta {}");
69
70 use_hook(|| {
71 let document = document();
72 document.create_meta(props);
73 });
74
75 VNode::empty()
76}