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

restructured posts and content, added a about page

+51
README.md
···
+
# 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 Jinja, 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).
+
+7
content/pages/about.md
···
+
---
+
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.
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
···
use crate::structs::{BlogInfo, IndexPostEntry};
pub fn get_blog_entry_markdown(path:&String) -> Result<Markdown,Error> {
-
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<IndexPostEntry> {
let mut post_vec:Vec<IndexPostEntry> = 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 {
+4 -1
src/handlers.rs
···
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()
}
+2 -2
src/main.rs
···
}
-
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 {
-4
templates/about.html
···
{% block content %}
-
<h2> yepper yapper yapper</h2>
-
-
<p> this is an about page </p>
-
{{ about_content|safe }}
{% endblock %}
+1 -1
templates/layout.html
···
</div>
<div class="float:right">
-
<a href="/about">About</a> |
+
<a href="/about.html">About</a> |
<a href="assets/duck.asc">PGP</a> |
<a href="mailto:duck@technoduck.me">Mail</a>
</div>