diff --git a/README.md b/README.md new file mode 100644 index 0000000..f492ddf --- /dev/null +++ b/README.md @@ -0,0 +1,51 @@ +# Staticrustator (being workshopped) + +After struggling with rewriting personnal website in a myriad of ways, all in some way unsatisfying, +I have decided to write my own statis site generator. + +Heavily inspired by [Saait](https://codemadness.org/git/saait/), since that is what I have been using previously. + +To build +```bash +cargo build +``` + +and to create the website structure +```bash +cargo run +``` + +This will create the folder `output` then you can sync to your vpc, or however you serve stataic files. + +------- +## File organization + +The posts are taken from `posts/` folder, are structured as markdown files, with a front matter in yaml for the date, and title of the post. + + +Example: +```markdown +--- +title: Pantheon +date: 2024-03-03 +--- +# WATCH PANTHEON + +## I DO NOT CARE WHAT DAY IT IS + +### HERE'S YOUR PLAN + +1. Wake up. +2. Open whatever device you watch things on. +3. Obtain, legally or illegaly, by any means necessary, 2 (two) seasons of Pantheon, created by Craig Silverstein based on short stories by Ken Liu. +4. Binge the 2 sesons in a single night (it is feasable I checked) + +Thank you for coming to my Ted Talk. +``` + +Additional pages such as `about` is also taken from there, however you could modify the about template in `templates` folder. +[Askama](https://github.com/djc/askama) is a rendering engine based on Junja, so it is rather straight forward to use, +but also it can take rust `structs` to hold template context, which is very nice. + +I have not yet integrated htmx into is, for faster loads of the post body,but that's for the future (also I hate js). + diff --git a/content/pages/about.md b/content/pages/about.md new file mode 100644 index 0000000..a036aae --- /dev/null +++ b/content/pages/about.md @@ -0,0 +1,7 @@ +--- +title:about page +date:01-09-2024 +--- +# Welcome to my site! + +Inspired originally by the yesterweb ring, a small portion of the internet where I post (rarely) about stuff i think i make that is cool. diff --git a/posts/000-genesis.md b/content/posts/000-genesis.md similarity index 100% rename from posts/000-genesis.md rename to content/posts/000-genesis.md diff --git a/posts/001-bash_blogger.md b/content/posts/001-bash_blogger.md similarity index 100% rename from posts/001-bash_blogger.md rename to content/posts/001-bash_blogger.md diff --git a/posts/002-services.md b/content/posts/002-services.md similarity index 100% rename from posts/002-services.md rename to content/posts/002-services.md diff --git a/posts/003-led_hoop.md b/content/posts/003-led_hoop.md similarity index 100% rename from posts/003-led_hoop.md rename to content/posts/003-led_hoop.md diff --git a/posts/004-pantheon.md b/content/posts/004-pantheon.md similarity index 100% rename from posts/004-pantheon.md rename to content/posts/004-pantheon.md diff --git a/posts/005-regenesis.md b/content/posts/005-regenesis.md similarity index 100% rename from posts/005-regenesis.md rename to content/posts/005-regenesis.md diff --git a/src/blog_entries.rs b/src/blog_entries.rs index d4093d3..7c24f2e 100644 --- a/src/blog_entries.rs +++ b/src/blog_entries.rs @@ -5,15 +5,15 @@ use markdown_parser::*; use crate::structs::{BlogInfo, IndexPostEntry}; pub fn get_blog_entry_markdown(path:&String) -> Result { - let location = format!("posts/{path}.md").to_string(); + let location = format!("content/posts/{path}.md").to_string(); read_file(Path::new(&location)) } pub fn get_all_markdowns() -> Vec { let mut post_vec:Vec = Vec::new(); - let mr_dir_iter = match read_dir("posts/") { + let mr_dir_iter = match read_dir("content/posts") { Ok(iter) => iter, - Err(err) => panic!("could ls files, err {err}") + Err(err) => panic!("couldnt ls files, err {err}") }; for entry in mr_dir_iter { diff --git a/src/handlers.rs b/src/handlers.rs index a55dc02..c4b89f6 100644 --- a/src/handlers.rs +++ b/src/handlers.rs @@ -11,7 +11,10 @@ pub fn index() -> String { pub fn about() -> String { - let about_content = parse_markdown("about"); + + let about_markdown = markdown_parser::read_file("content/pages/about.md").expect("Could no find about.md file in content/pages/ folder"); + + let about_content = parse_markdown(about_markdown.content()); let page_content = AboutTemplate{about_content: &about_content}; page_content.to_string() } diff --git a/src/main.rs b/src/main.rs index afc8c47..5d28920 100644 --- a/src/main.rs +++ b/src/main.rs @@ -34,9 +34,9 @@ fn main() { } - let post_dir_iter = match read_dir("posts/") { + let post_dir_iter = match read_dir("content/posts/") { Ok(iter) => iter, - Err(err) => panic!("could ls files, err {err}") + Err(err) => panic!("couldnt ls files, err {err}") }; for entry in post_dir_iter { diff --git a/templates/about.html b/templates/about.html index fd47dbb..a57112e 100644 --- a/templates/about.html +++ b/templates/about.html @@ -6,10 +6,6 @@ {% block content %} -

yepper yapper yapper

- -

this is an about page

- {{ about_content|safe }} {% endblock %} diff --git a/templates/layout.html b/templates/layout.html index 9339a54..9bc644f 100644 --- a/templates/layout.html +++ b/templates/layout.html @@ -24,7 +24,7 @@
- About | + About | PGP | Mail