diff options
Diffstat (limited to 'src/main.rs')
| -rw-r--r-- | src/main.rs | 84 |
1 files changed, 81 insertions, 3 deletions
diff --git a/src/main.rs b/src/main.rs index 7ad56c2..5882335 100644 --- a/src/main.rs +++ b/src/main.rs @@ -12,12 +12,89 @@ struct Data { stories: Vec<Story>, } +impl page::Page for Data { + fn page_title() -> String { + String::from("Home") + } + + fn alternative_htmlfilename() -> Option<String> { + Some(String::from("index")) + } + + fn render_content(&self) -> Markup { + let last_story = self.stories.first(); + html!( + @if let Some(story) = last_story { + div class="latest-story" { + h2 { "Latest Story" } + h3 { + (story.name) + } + p { (story.description) } + ul { + li { "Language: " (story.language) } + li { + a href=(&story.format_pdf_path()) download + { + "PDF" + } + } + } + + } + } + ) + } + + fn content_style() -> Markup { + html!( + """ + h2 { + font-size: 2.5rem; + color: #2F3C57; + text-decoration: 0.1rem solid underline black; + } + + h3 { + font-size: 1.8rem; + color: #2F3C57; + padding: 2rem 0; + } + + .latest-story { + padding: 3rem; + margin: 3rem; + text-align: left; + background-color: #FFD1A3; + * { + margin: 1rem 0; + } + + p { + font-size: 1.2rem; + } + } + + a { + text-decoration: underline; + color: #3D1D49; + } + + ul { + list-style: none; + } + + """ + ) + } +} + impl page::Page for Vec<Story> { fn page_title() -> String { String::from("Stories") } - fn render_content(self) -> Markup { + fn render_content(&self) -> Markup { html!( @for story in self { (story.render_as_card()) @@ -111,7 +188,7 @@ struct Story { } impl Story { - fn render_as_card(self) -> Markup { + fn render_as_card(&self) -> Markup { html!(div class="story-card" { card { h2 { (self.name) } @@ -147,7 +224,8 @@ impl Story { fn main() -> Result<()> { let data_file_content = std::fs::read_to_string("data.toml").with_context(|| "Failed to read data.toml")?; - let data: Data = toml::from_str(&data_file_content)?; + let mut data: Data = toml::from_str(&data_file_content)?; data.stories.write_page()?; + data.write_page()?; Ok(()) } |
