Static site generator + my presonnal website written in rust for some reason.

restructured posts and content, added a about page

+68 -11
+51
README.md
··· 1 + # Staticrustator (being workshopped) 2 + 3 + After struggling with rewriting personnal website in a myriad of ways, all in some way unsatisfying, 4 + I have decided to write my own statis site generator. 5 + 6 + Heavily inspired by [Saait](https://codemadness.org/git/saait/), since that is what I have been using previously. 7 + 8 + To build 9 + ```bash 10 + cargo build 11 + ``` 12 + 13 + and to create the website structure 14 + ```bash 15 + cargo run 16 + ``` 17 + 18 + This will create the folder `output` then you can sync to your vpc, or however you serve stataic files. 19 + 20 + ------- 21 + ## File organization 22 + 23 + 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. 24 + 25 + 26 + Example: 27 + ```markdown 28 + --- 29 + title: Pantheon 30 + date: 2024-03-03 31 + --- 32 + # WATCH PANTHEON 33 + 34 + ## I DO NOT CARE WHAT DAY IT IS 35 + 36 + ### HERE'S YOUR PLAN 37 + 38 + 1. Wake up. 39 + 2. Open whatever device you watch things on. 40 + 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. 41 + 4. Binge the 2 sesons in a single night (it is feasable I checked) 42 + 43 + Thank you for coming to my Ted Talk. 44 + ``` 45 + 46 + Additional pages such as `about` is also taken from there, however you could modify the about template in `templates` folder. 47 + [Askama](https://github.com/djc/askama) is a rendering engine based on Jinja, so it is rather straight forward to use, 48 + but also it can take rust `structs` to hold template context, which is very nice. 49 + 50 + 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). 51 +
+7
content/pages/about.md
··· 1 + --- 2 + title:about page 3 + date:01-09-2024 4 + --- 5 + # Welcome to my site! 6 + 7 + 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.
posts/000-genesis.md content/posts/000-genesis.md
posts/001-bash_blogger.md content/posts/001-bash_blogger.md
posts/002-services.md content/posts/002-services.md
posts/003-led_hoop.md content/posts/003-led_hoop.md
posts/004-pantheon.md content/posts/004-pantheon.md
posts/005-regenesis.md content/posts/005-regenesis.md
+3 -3
src/blog_entries.rs
··· 5 5 use crate::structs::{BlogInfo, IndexPostEntry}; 6 6 7 7 pub fn get_blog_entry_markdown(path:&String) -> Result<Markdown,Error> { 8 - let location = format!("posts/{path}.md").to_string(); 8 + let location = format!("content/posts/{path}.md").to_string(); 9 9 read_file(Path::new(&location)) 10 10 } 11 11 12 12 pub fn get_all_markdowns() -> Vec<IndexPostEntry> { 13 13 let mut post_vec:Vec<IndexPostEntry> = Vec::new(); 14 - let mr_dir_iter = match read_dir("posts/") { 14 + let mr_dir_iter = match read_dir("content/posts") { 15 15 Ok(iter) => iter, 16 - Err(err) => panic!("could ls files, err {err}") 16 + Err(err) => panic!("couldnt ls files, err {err}") 17 17 }; 18 18 19 19 for entry in mr_dir_iter {
+4 -1
src/handlers.rs
··· 11 11 12 12 pub fn about() -> String { 13 13 14 - let about_content = parse_markdown("about"); 14 + 15 + let about_markdown = markdown_parser::read_file("content/pages/about.md").expect("Could no find about.md file in content/pages/ folder"); 16 + 17 + let about_content = parse_markdown(about_markdown.content()); 15 18 let page_content = AboutTemplate{about_content: &about_content}; 16 19 page_content.to_string() 17 20 }
+2 -2
src/main.rs
··· 34 34 } 35 35 36 36 37 - let post_dir_iter = match read_dir("posts/") { 37 + let post_dir_iter = match read_dir("content/posts/") { 38 38 Ok(iter) => iter, 39 - Err(err) => panic!("could ls files, err {err}") 39 + Err(err) => panic!("couldnt ls files, err {err}") 40 40 }; 41 41 42 42 for entry in post_dir_iter {
-4
templates/about.html
··· 6 6 7 7 {% block content %} 8 8 9 - <h2> yepper yapper yapper</h2> 10 - 11 - <p> this is an about page </p> 12 - 13 9 {{ about_content|safe }} 14 10 15 11 {% endblock %}
+1 -1
templates/layout.html
··· 24 24 </div> 25 25 26 26 <div class="float:right"> 27 - <a href="/about">About</a> | 27 + <a href="/about.html">About</a> | 28 28 <a href="assets/duck.asc">PGP</a> | 29 29 <a href="mailto:duck@technoduck.me">Mail</a> 30 30 </div>