1use super::*;
2
3#[derive(Debug, Clone, Default, PartialEq, Eq, serde::Serialize, serde::Deserialize)]
4#[serde(default)]
5#[serde(rename_all = "snake_case")]
6#[cfg_attr(feature = "unstable", serde(deny_unknown_fields))]
7#[cfg_attr(not(feature = "unstable"), non_exhaustive)]
8pub struct Collection {
9 pub title: Option<liquid_core::model::KString>,
10 pub description: Option<liquid_core::model::KString>,
11 pub dir: Option<RelPath>,
12 pub drafts_dir: Option<RelPath>,
13 pub order: SortOrder,
14 pub rss: Option<RelPath>,
15 pub jsonfeed: Option<RelPath>,
16 pub publish_date_in_filename: bool,
17 pub default: Frontmatter,
18}
19
20impl From<PostCollection> for Collection {
21 fn from(other: PostCollection) -> Collection {
22 let PostCollection {
23 title,
24 description,
25 dir,
26 drafts_dir,
27 order,
28 rss,
29 jsonfeed,
30 publish_date_in_filename,
31 default,
32 } = other;
33 Self {
34 title,
35 description,
36 dir: Some(dir),
37 drafts_dir,
38 order,
39 rss,
40 jsonfeed,
41 publish_date_in_filename,
42 default,
43 }
44 }
45}
46
47impl From<PageCollection> for Collection {
48 fn from(other: PageCollection) -> Collection {
49 let PageCollection { default } = other;
50 let default = default.merge(&Frontmatter {
52 excerpt_separator: Some("".into()),
53 ..Default::default()
54 });
55 Self {
56 default,
57 dir: Some(RelPath::new()),
58 order: SortOrder::None,
59 ..Default::default()
60 }
61 }
62}
63
64#[derive(Debug, Clone, PartialEq, Eq, Default, serde::Serialize, serde::Deserialize)]
65#[serde(default)]
66#[serde(rename_all = "snake_case")]
67#[cfg_attr(feature = "unstable", serde(deny_unknown_fields))]
68#[cfg_attr(not(feature = "unstable"), non_exhaustive)]
69pub struct PageCollection {
70 pub default: Frontmatter,
71}
72
73#[derive(Debug, Clone, PartialEq, Eq, serde::Serialize, serde::Deserialize)]
74#[serde(default)]
75#[serde(rename_all = "snake_case")]
76#[cfg_attr(feature = "unstable", serde(deny_unknown_fields))]
77#[cfg_attr(not(feature = "unstable"), non_exhaustive)]
78pub struct PostCollection {
79 pub title: Option<liquid_core::model::KString>,
80 pub description: Option<liquid_core::model::KString>,
81 pub dir: RelPath,
82 pub drafts_dir: Option<RelPath>,
83 pub order: SortOrder,
84 pub rss: Option<RelPath>,
85 pub jsonfeed: Option<RelPath>,
86 pub publish_date_in_filename: bool,
87 pub default: Frontmatter,
88}
89
90impl Default for PostCollection {
91 fn default() -> Self {
92 Self {
93 title: Default::default(),
94 description: Default::default(),
95 dir: RelPath::from_unchecked("posts"),
96 drafts_dir: Default::default(),
97 order: Default::default(),
98 rss: Default::default(),
99 jsonfeed: Default::default(),
100 publish_date_in_filename: true,
101 default: Default::default(),
102 }
103 }
104}
105
106#[derive(Debug, Eq, PartialEq, Hash, Copy, Clone, serde::Serialize, serde::Deserialize)]
107#[cfg_attr(feature = "preview_unstable", serde(rename_all = "snake_case"))]
108#[cfg_attr(feature = "unstable", serde(deny_unknown_fields))]
109#[cfg_attr(not(feature = "unstable"), non_exhaustive)]
110#[derive(Default)]
111pub enum SortOrder {
112 None,
113 Asc,
114 #[default]
115 Desc,
116 #[cfg(not(feature = "unstable"))]
117 #[doc(hidden)]
118 #[serde(other)]
119 Unknown,
120}