diff --git a/assets/static/maggie-ellie-comfy.jpeg b/assets/static/maggie-ellie-comfy.jpeg new file mode 100644 index 0000000..c4bac3b Binary files /dev/null and b/assets/static/maggie-ellie-comfy.jpeg differ diff --git a/assets/templates/home.html b/assets/templates/home.html new file mode 100644 index 0000000..ff78bb1 --- /dev/null +++ b/assets/templates/home.html @@ -0,0 +1,26 @@ + + + + + Home + + + + + +{% include "nav.html" %} + + +

Hello! I'm Price, a Linux user and Neovim addict. This necessarily means I am either bald or balding. Oh, also I + sometimes write Rust. This page is generated from a Rust static site generator I wrote, it's not very good but it + makes me happy. I'm a big fan of reproducible systems and infrastructure, though I'm not sure if I'm sold on NixOS + just yet. I hold it as a dumb source of pride that I can wipe my laptop and have everything back to normal within 20 + minutes depending on how nice Github's rate limit wants to play. Hit me up at my email if you want to get in contact.

+

Maggie and Ellie say hi: Black labrador and yellow
+      labrador dogs sleeping on bed with blankets over them

+ + +{% include "footer.html" %} + + \ No newline at end of file diff --git a/src/main.rs b/src/main.rs index ed053e3..9d6c8e1 100644 --- a/src/main.rs +++ b/src/main.rs @@ -1,14 +1,14 @@ use anyhow::{Context, Ok}; -use clap::Parser; use blog::{ markdown::article::{Article, FrontMatter}, page_gen::{ articles::Articles, - tags::{TagArticles, Tags}, + tags::{TagArticles, Tags}, home::Home, }, TemplateRenderer, }; -use std::{collections::HashMap, path::PathBuf}; +use clap::Parser; +use std::{collections::HashMap, fs::copy, path::PathBuf}; use tera::Tera; #[derive(Parser, Debug)] @@ -30,8 +30,8 @@ struct Args { fn main() -> anyhow::Result<()> { let comrak_settings = blog::markdown::MDComrakSettings::default().unwrap(); let posts_dir = PathBuf::from(concat!(env!("CARGO_MANIFEST_DIR"), "/posts/")); - let posts_walkable = std::fs::read_dir(&posts_dir) - .context("Unable to read posts directory!")?; + let posts_walkable = + std::fs::read_dir(&posts_dir).context("Unable to read posts directory!")?; let out_path = PathBuf::from(concat!(env!("CARGO_MANIFEST_DIR"), "/out")); std::fs::create_dir_all(&out_path) .context(format!("Unable to create out directory at '{out_path:?}'"))?; @@ -78,6 +78,14 @@ fn main() -> anyhow::Result<()> { } println!("Finished rendering Article templates"); + println!("Rendering Articles Page"); + let articles_page = Articles::new(&article_links) + .render_template(&tera) + .context("Main Articles Page Rendering Error")?; + let articles_write_path = &out_path.join("articles.html"); + write_file(&articles_write_path, articles_page.as_bytes())?; + println!("Finished Rendering Articles Page"); + println!("Rendering Tags Page"); let tags_page = Tags::new(&detected_tags_article.keys().collect::>()) .render_template(&tera) @@ -87,14 +95,6 @@ fn main() -> anyhow::Result<()> { write_file(&tags_write_path, tags_page.as_bytes())?; println!("Finished Rendering Tags Page"); - println!("Rendering Articles Page"); - let articles_page = Articles::new(&article_links) - .render_template(&tera) - .context("Main Articles Page Rendering Error")?; - let articles_write_path = &out_path.join("articles.html"); - write_file(&articles_write_path, articles_page.as_bytes())?; - println!("Finished Rendering Articles Page"); - println!("Rendering Individual Tag Pages"); for (tag, article_link) in detected_tags_article.iter() { println!("Rendering Tag Page: {}", &tag); @@ -106,9 +106,21 @@ fn main() -> anyhow::Result<()> { } println!("Finished rendering Individual Tag Pages"); + println!("Rendering Home Page"); + let home_page = Home::render_template(&Home { }, &tera)?; + write_file(&out_path.join("home.html"), home_page.as_bytes())?; + println!("Finished rendering Home Page"); + let base_asset_dir = PathBuf::from(concat!(env!("CARGO_MANIFEST_DIR"), "/assets/")); copy_recursive(&base_asset_dir.join("style/"), &out_path.join("style"))?; - copy_recursive(&posts_dir.join("assets/"), &out_path.join("articles/assets"))?; + copy_recursive( + &base_asset_dir.join("static/"), + &out_path.join("assets/static/"), + )?; + copy_recursive( + &posts_dir.join("assets/"), + &out_path.join("articles/assets"), + )?; Ok(()) } @@ -139,4 +151,4 @@ fn write_file(file_path: &PathBuf, contents: &[u8]) -> anyhow::Result<()> { } std::fs::write(file_path, contents).context(format!("Failed to write to {file_path:?}")) -} +} \ No newline at end of file diff --git a/src/page_gen/home.rs b/src/page_gen/home.rs new file mode 100644 index 0000000..8a63459 --- /dev/null +++ b/src/page_gen/home.rs @@ -0,0 +1,10 @@ +use crate::TemplateRenderer; + +pub struct Home {} + +impl TemplateRenderer for Home { + fn render_template(&self, tera: &tera::Tera) -> anyhow::Result { + let empty_context = tera::Context::new(); + Ok(tera.render("home.html", &empty_context)?) + } +} \ No newline at end of file diff --git a/src/page_gen/mod.rs b/src/page_gen/mod.rs index cd4a95d..f835e49 100644 --- a/src/page_gen/mod.rs +++ b/src/page_gen/mod.rs @@ -3,9 +3,10 @@ use serde::Serialize; pub mod articles; pub mod tags; +pub mod home; #[derive(Serialize)] pub struct ArticleLink<'a> { frontmatter: &'a FrontMatter, link: &'a String, -} +} \ No newline at end of file