html_types/semantic/
head.rs1use super::{Script, StyleSheet};
2use crate::{
3 node::{Element, Node},
4 text::Text,
5};
6
7pub struct Head {
8 pub title: Option<Text>,
9 pub styles: Vec<StyleSheet>,
10 pub scripts: Vec<Script>,
11}
12
13impl<'a> From<Head> for Element<'a, Vec<Node<'a>>> {
14 fn from(value: Head) -> Self {
15 let mut head = Element::head();
16 match value.title {
17 Some(title) => {
18 let title = Element::title(title);
19 head.push(title)
20 }
21 None => (),
22 };
23
24 for style in value.styles {
25 let el: Node = style.into();
26 head.push(el);
27 }
28
29 for script in value.scripts {
30 let el: Node = script.into();
31 head.push(el);
32 }
33
34 head
35 }
36}