restructured posts and content, added a about page
This commit is contained in:
parent
aa502d4554
commit
f9bc5cdfa8
13 changed files with 68 additions and 11 deletions
51
README.md
Normal file
51
README.md
Normal file
|
@ -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 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
Normal file
7
content/pages/about.md
Normal file
|
@ -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.
|
|
@ -5,15 +5,15 @@ use markdown_parser::*;
|
|||
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 {
|
||||
|
|
|
@ -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()
|
||||
}
|
||||
|
|
|
@ -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 {
|
||||
|
|
|
@ -6,10 +6,6 @@
|
|||
|
||||
{% block content %}
|
||||
|
||||
<h2> yepper yapper yapper</h2>
|
||||
|
||||
<p> this is an about page </p>
|
||||
|
||||
{{ about_content|safe }}
|
||||
|
||||
{% endblock %}
|
||||
|
|
|
@ -24,7 +24,7 @@
|
|||
</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>
|
||||
|
|
Loading…
Reference in a new issue