Moving blog to posts for more general use of root path

This commit is contained in:
Awstin 2025-01-19 08:04:29 -05:00
parent fe5c27839f
commit 8a1a2c16e3
34 changed files with 22 additions and 22 deletions

View file

@ -88,7 +88,7 @@ date: 2021-07-05
It is important to take the time to ensure that the things that we create are as simple as possible while still doing everything they need to do.
It often makes them harder to make in the first place but the extra investment of time and energy upfront make maintaining and modifying them much simpler.
Overall it saves much more time then it takes, but the time saved is spread out over years and is less noticeable.
Kind of like good <a href="/blog/habits">habits</a> where the cost is now and the rewards are later.
Kind of like good <a href="/posts/habits">habits</a> where the cost is now and the rewards are later.
</p>
<p>

View file

@ -135,7 +135,7 @@ impl PsqlData for Article {
}
pub async fn load_articles(pool: &Pool<Postgres>) -> Result<(), Box<dyn Error>> {
let paths = fs::read_dir("blog/").unwrap();
let paths = fs::read_dir("posts/").unwrap();
for path_entry in paths {
let path: PathBuf = path_entry.unwrap().path();
let metadata = metadata(path.clone()).unwrap();

View file

@ -1,7 +1,7 @@
use serde::Deserialize;
pub mod admin;
pub mod blog;
pub mod posts;
pub mod projects;
pub mod root;
pub mod templates;

View file

@ -8,22 +8,22 @@ use axum::{
use sqlx::PgPool;
use std::{collections::HashMap, error::Error};
use super::templates::{ArticleTemplate, BlogFooterTemplate, BlogTemplate, HtmlTemplate};
use super::templates::{ArticleTemplate, PostFooterTemplate, PostTemplate, HtmlTemplate};
pub fn get_router() -> Router {
Router::new()
.route("/", get(blog))
.route("/", get(post))
.route("/:article", get(article))
}
async fn blog(Extension(pool): Extension<PgPool>) -> impl IntoResponse {
let blog_page = BlogTemplate {
async fn post(Extension(pool): Extension<PgPool>) -> impl IntoResponse {
let post_page = PostTemplate {
articles: match get_articles_date_sorted(&pool).await {
Ok(list) => list,
Err(_) => Vec::new(),
},
};
HtmlTemplate(blog_page)
HtmlTemplate(post_page)
}
async fn article(
@ -35,7 +35,7 @@ async fn article(
Ok(a) => *a,
Err(_) => return Err(StatusCode::NOT_FOUND),
};
let footer = BlogFooterTemplate {
let footer = PostFooterTemplate {
previous: match article.previous {
Some(a) => a,
None => "".to_string(),

View file

@ -23,7 +23,7 @@ use crate::{
use super::{
admin,
blog::{self, get_articles_date_sorted},
posts::{self, get_articles_date_sorted},
projects,
templates::{
AboutTemplate, AiTemplate, BlogrollTemplate, BooksTemplate, ContactTemplate, CookingTemplate, CreationTemplate, GiftsTemplate, HomeTemplate, HtmlTemplate, InterestsTemplate, LinksPageTemplate, LoginTemplate, MoneyTemplate, NowTemplate, ResumeTemplate, SignupTemplate, TechnologyTemplate, TimeTemplate, UsesTemplate, WorkTemplate
@ -37,7 +37,7 @@ pub fn get_router(pool: PgPool) -> Router {
let middleware_database = pool.clone();
Router::new()
.nest("/blog", blog::get_router())
.nest("/posts", posts::get_router())
.nest("/projects", projects::get_router())
.nest("/admin", admin::get_router())
.nest_service(

View file

@ -49,8 +49,8 @@ pub struct LinksPageTemplate {
}
#[derive(Template)]
#[template(path = "blog.html")]
pub struct BlogTemplate {
#[template(path = "posts.html")]
pub struct PostTemplate {
pub articles: Vec<Article>,
}
@ -128,7 +128,7 @@ pub struct CreationTemplate {}
#[derive(Template)]
#[template(path = "blog_footer.html")]
pub struct BlogFooterTemplate {
pub struct PostFooterTemplate {
pub previous: String,
pub next: String,
}

View file

@ -33,7 +33,7 @@
</g>
</svg>
<li>
<a id="blog" href="/blog">
<a id="posts" href="/posts">
<svg width="40" height="40" viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg" stroke="#8ec07c" transform="rotate(0)">
<title>Posts</title>
<g id="SVGRepo_bgCarrier" stroke-width="0"></g>

View file

@ -55,8 +55,8 @@
<h4>Reflections from Books I have read</h4>
<ul class="no-bul">
<li><a href="/blog/deepwork">Deep Work</a></li>
<li><a href="/blog/mfn">A Mind for Numbers</a></li>
<li><a href="/posts/deepwork">Deep Work</a></li>
<li><a href="/posts/mfn">A Mind for Numbers</a></li>
</ul>
<h3>

View file

@ -6,7 +6,7 @@
<p>
Creating things is something that my family has always held as something very important.
We tend to operate more on the building fixing side of things but there is something sacred in any act of creation.
I wrote about this feeling in <a href="/blog/mm">Midnight Musings</a> when I was unable to sleep.
I wrote about this feeling in <a href="/posts/mm">Midnight Musings</a> when I was unable to sleep.
</p>
<p>
I dabble.

View file

@ -31,16 +31,16 @@
</section><br>
<section id="blog">
<h2>Blog</h2>
<h2>Posts</h2>
<p>
Chronological <a href="blog">stuff</a> that I have written.
Chronological <a href="/posts">stuff</a> that I have written.
Not adding to this as much with the focus more on less time sensitive information, but if something is timely then will still be added as a blog post.
</p>
<h3>Most Recent Posts</h3>
<ul class="no-bul">
{% for article in recent_articles %}
<li><a href="/blog/{{article.reference}}">{{article.title}}</a></li>
<li><a href="/posts/{{article.reference}}">{{article.title}}</a></li>
{% endfor %}
</ul>
</section><br>

View file

@ -4,7 +4,7 @@
{% block content %}
<ul class="no-bul">
{% for article in articles %}
<li><a href="/blog/{{article.reference}}">{{article.title}}</a></li>
<li><a href="/posts/{{article.reference}}">{{article.title}}</a></li>
{% endfor %}
</ul>
{% endblock %}