diff options
| author | WriterV2 <primary-v2@protonmail.com> | 2026-05-11 23:52:49 +0200 |
|---|---|---|
| committer | WriterV2 <primary-v2@protonmail.com> | 2026-05-11 23:52:49 +0200 |
| commit | 5760f597eb17eab5abe6a3ae6c905ad9e111dc46 (patch) | |
| tree | 853c9062cbc911f9ebe287eba3210ecde5721949 /src/data.rs | |
| parent | 79618992153be5348f02ad91c8b91bd883c0b295 (diff) | |
Refactor page and story
Diffstat (limited to 'src/data.rs')
| -rw-r--r-- | src/data.rs | 98 |
1 files changed, 98 insertions, 0 deletions
diff --git a/src/data.rs b/src/data.rs new file mode 100644 index 0000000..2e5b3d1 --- /dev/null +++ b/src/data.rs @@ -0,0 +1,98 @@ +use crate::page; +use crate::story; +use maud::{html, Markup}; +use serde::Deserialize; + +#[derive(Deserialize)] +pub struct Data { + pub stories: Vec<story::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" lang=(story.html_lang_value()) { + h2 lang="en" { "Latest Story" } + h3 { + (story.name) + } + @if let Some(content_warnings) = story.render_content_warnings() { + (content_warnings) + } + + p { (story.description) } + ul lang="en" { + 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; + hyphens: auto; + * { + margin: 1rem 0; + } + + p { + font-size: 1.2rem; + } +} + +a { + text-decoration: underline; + color: #3D1D49; +} + +ul { + list-style: none; +} + +.content-warning { + background-color: #EC7981; + margin: 2rem 0; + padding: 0.3rem; + width: fit-content; +} + + """ + ) + } +} |
