1use sova_core::extend::RouteValue;
4use std::borrow::Cow;
5
6#[derive(Debug, Clone, Default)]
8pub struct MetaPage {
9 pub title: Option<String>,
10 pub description: Option<String>,
11 pub image: Option<String>,
12 pub noindex: bool,
13 pub canonical_path: Option<String>,
14 pub moved_to: Option<String>,
15 pub og_type: Option<String>,
16 pub manual: bool,
18}
19
20impl MetaPage {
21 pub fn new() -> Self {
22 Self::default()
23 }
24
25 pub fn title(mut self, t: impl Into<String>) -> Self {
26 self.title = Some(t.into());
27 self
28 }
29
30 pub fn description(mut self, d: impl Into<String>) -> Self {
31 self.description = Some(d.into());
32 self
33 }
34
35 pub fn image(mut self, i: impl Into<String>) -> Self {
36 self.image = Some(i.into());
37 self
38 }
39
40 pub fn noindex(mut self) -> Self {
41 self.noindex = true;
42 self
43 }
44
45 pub fn canonical_path(mut self, p: impl Into<String>) -> Self {
46 self.canonical_path = Some(p.into());
47 self
48 }
49
50 pub fn moved_to(mut self, p: impl Into<String>) -> Self {
51 self.moved_to = Some(p.into());
52 self
53 }
54
55 pub fn og_type(mut self, t: impl Into<String>) -> Self {
56 self.og_type = Some(t.into());
57 self
58 }
59
60 pub fn manual(mut self) -> Self {
61 self.manual = true;
62 self
63 }
64}
65
66impl RouteValue for MetaPage {
67 fn label(&self) -> Cow<'static, str> {
68 if self.noindex {
69 Cow::Borrowed("MetaPage(noindex)")
70 } else if let Some(ref t) = self.title {
71 Cow::Owned(format!("MetaPage({t})"))
72 } else {
73 Cow::Borrowed("MetaPage")
74 }
75 }
76}