diff options
author | Gabriel A. Giovanini <mail@gabrielgio.me> | 2022-06-09 20:10:19 +0200 |
---|---|---|
committer | Gabriel A. Giovanini <mail@gabrielgio.me> | 2022-06-09 20:10:19 +0200 |
commit | b4472b41214eeeacce071df41bf0f782e1f16d6d (patch) | |
tree | efb666792785ba98c177990cfc349cdb9d6a56c7 /src/blog.rs | |
parent | e44658641b75076b702e690df166820c1d133f24 (diff) | |
download | macroblog.rs-b4472b41214eeeacce071df41bf0f782e1f16d6d.tar.gz macroblog.rs-b4472b41214eeeacce071df41bf0f782e1f16d6d.tar.bz2 macroblog.rs-b4472b41214eeeacce071df41bf0f782e1f16d6d.zip |
feat: Move from pico to custom css
Use css from my current blog, which is a lot smaller. The text itself
looks good but the code still breaks the page.
Metrics:
- hyper: 16.37 KB / 16.47 KB transferred
- 1 request
Diffstat (limited to 'src/blog.rs')
-rw-r--r-- | src/blog.rs | 32 |
1 files changed, 14 insertions, 18 deletions
diff --git a/src/blog.rs b/src/blog.rs index 6bbda49..0fa9543 100644 --- a/src/blog.rs +++ b/src/blog.rs @@ -1,9 +1,9 @@ +use chrono::NaiveDate; +use regex::Regex; use rust_embed::RustEmbed; use sailfish::TemplateOnce; -use chrono::NaiveDate; -use regex::{Regex}; +use std::cmp::{Eq, Ord, PartialEq, PartialOrd}; use std::str; -use std::cmp::{PartialOrd, Ord, PartialEq, Eq}; const BLOG_REGEX: &str = r"(?P<date>[\d]{4}-[\d]{2}-[\d]{2})(?P<title>[a-zA-Z0-9-_]*)"; @@ -11,7 +11,6 @@ const BLOG_REGEX: &str = r"(?P<date>[\d]{4}-[\d]{2}-[\d]{2})(?P<title>[a-zA-Z0-9 #[folder = "content/posts/"] struct PostAsset; - #[derive(TemplateOnce)] #[template(path = "index.html")] struct IndexTemplate { @@ -23,7 +22,7 @@ struct IndexTemplate { struct PostTemplate { content: String, title: String, - date: String + date: String, } #[derive(PartialEq, Eq, PartialOrd, Ord)] @@ -43,12 +42,11 @@ impl BlogEntry { BlogEntry { title: String::from(title), file: String::from(path), - datetime: NaiveDate::parse_from_str(date, "%Y-%m-%d").unwrap() + datetime: NaiveDate::parse_from_str(date, "%Y-%m-%d").unwrap(), } } pub fn read_assets() -> Vec<BlogEntry> { - let mut entries: Vec<BlogEntry> = PostAsset::iter() .map(|e| format!("{}", e)) .map(|e| BlogEntry::new(&e)) @@ -61,29 +59,27 @@ impl BlogEntry { } fn get_file_content(path: &str) -> String { - let buffer = PostAsset::get(path) - .unwrap() - .data - .into_owned(); + let buffer = PostAsset::get(path).unwrap().data.into_owned(); return String::from_utf8(buffer).unwrap(); } - pub fn render_post_page(path: &String) -> String { let blog = BlogEntry::new(path); PostTemplate { content: get_file_content(path), title: blog.title, - date: blog.datetime.format("%Y-%m-%d").to_string() + date: blog.datetime.format("%Y-%m-%d").to_string(), } - .render_once() - .unwrap() + .render_once() + .unwrap() } pub fn render_index_page() -> String { - IndexTemplate { posts: BlogEntry::read_assets() } - .render_once() - .unwrap() + IndexTemplate { + posts: BlogEntry::read_assets(), + } + .render_once() + .unwrap() } |