1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
//! A series of components used across the site.
use crate::data::*;
use maud::{html, Markup, DOCTYPE};

/// The `<head>` portion of the webpage.
pub fn head(meta: &MetaData) -> Markup {
    html! {
        head {
            meta charset=(meta.charset);
            title { (meta.title) }
            meta name="description" content=(meta.description);
            meta name="viewport" content="width=device-width, initial-scale=1";
            meta name="theme-color" content=(meta.theme_color);
            @for css in meta.css {
                (css)
            }
            @for js in meta.scripts {
                (js)
            }
        }
    }
}
/// The `<header>` portion of the webpage. Displays logos and menus.
pub fn header(meta: &MetaData) -> Markup {
    html! {
        header.site-header {
            @if let Some(logo) = meta.logo {
                (logo)
            }
            @if let Some(menu) = meta.menu {
                (menu)
            }
        }
    }
}
/// The `<footer>` portion of the webpage. Displays copyright and contact information.
pub fn footer(meta: &MetaData) -> Markup {
    html! {
        footer.site-footer {
            @if let Some(contact) = meta.contact {
                (contact)
            }
            (meta.copyright)
        }
    }
}
/// The `<body>` portion of the webpage. Wraps the main content and offsets it from the header and
/// footer.
pub fn body(m: Markup, meta: &MetaData) -> Markup {
    html! {
        body {
            div.bg-img {}
            (header(meta))
            main.site-body {
                (m)
            }
            (footer(meta))
        }
    }
}
/// A template of the page with its `<DOCTYPE>` and `<html>` tags.
pub fn page(m: Markup, meta: &MetaData) -> Markup {
    html! {
        (DOCTYPE)
        html lang=(meta.lang) {
            (head(&meta))
            (body(m, &meta))
        }
    }
}
/// A template of a page. Uses default [`MetaData`](crate::data::MetaData) if not provided.
pub fn basic_page(m: Markup, meta_data: Option<&MetaData>) -> Markup {
    let store;
    let meta;
    if let Some(meta_ref) = meta_data {
        meta = meta_ref;
    } else {
        store = MetaData::default();
        meta = &store;
    }
    page(m, meta)
}