remove old svelte web source
This commit is contained in:
9
src/pages/admin.rs
Normal file
9
src/pages/admin.rs
Normal file
@ -0,0 +1,9 @@
|
||||
use askama::Template;
|
||||
|
||||
#[derive(Template)]
|
||||
#[template(path = "admin.html")]
|
||||
pub struct AdminPageTemplate {}
|
||||
|
||||
pub async fn render_admin() -> AdminPageTemplate {
|
||||
AdminPageTemplate {}
|
||||
}
|
74
src/pages/blog_post_list.rs
Normal file
74
src/pages/blog_post_list.rs
Normal file
@ -0,0 +1,74 @@
|
||||
use askama::Template;
|
||||
use axum::{extract::Path, http::StatusCode};
|
||||
use tokio::try_join;
|
||||
|
||||
use crate::{
|
||||
blog_posts::{
|
||||
blog_post_model::{BlogPostMetadata, BLOG_POST_PATH},
|
||||
tag_list::get_popular_blog_tags,
|
||||
},
|
||||
components::site_header::{HeaderProps, Link},
|
||||
filters,
|
||||
post_utils::{post_listing::get_post_list, post_parser::ParseResult},
|
||||
projects::{featured_projects::get_featured_projects, project_model::ProjectMetadata},
|
||||
};
|
||||
|
||||
#[derive(Template)]
|
||||
#[template(path = "blog_post_list.html")]
|
||||
pub struct PostListTemplate {
|
||||
pub title: String,
|
||||
pub posts: Vec<ParseResult<BlogPostMetadata>>,
|
||||
pub tag: Option<String>,
|
||||
pub header_props: HeaderProps,
|
||||
pub blog_tags: Vec<String>,
|
||||
pub featured_projects: Vec<ParseResult<ProjectMetadata>>,
|
||||
}
|
||||
|
||||
pub async fn render_blog_post_list(
|
||||
tag: Option<Path<String>>,
|
||||
) -> Result<PostListTemplate, StatusCode> {
|
||||
// I will forget what happens here in a week. But essentially it's pattern matching and shadowing
|
||||
let tag = tag.map(|Path(tag)| tag);
|
||||
|
||||
let (blog_tags, featured_projects, mut post_list) = try_join!(
|
||||
get_popular_blog_tags(),
|
||||
get_featured_projects(),
|
||||
get_post_list::<BlogPostMetadata>(BLOG_POST_PATH)
|
||||
)?;
|
||||
|
||||
post_list.sort_by_key(|post| post.metadata.date);
|
||||
post_list.retain(|post| post.metadata.published);
|
||||
post_list.reverse();
|
||||
|
||||
let posts = match &tag {
|
||||
Some(tag) => post_list
|
||||
.into_iter()
|
||||
.filter(|post| {
|
||||
post.metadata
|
||||
.tags
|
||||
.iter()
|
||||
.map(|post_tag| post_tag.to_lowercase())
|
||||
.collect::<String>()
|
||||
.contains(&tag.to_lowercase())
|
||||
})
|
||||
.collect(),
|
||||
None => post_list,
|
||||
};
|
||||
|
||||
let header_props = match tag {
|
||||
Some(_) => HeaderProps::with_back_link(Link {
|
||||
href: "/blog".to_string(),
|
||||
label: "All posts".to_string(),
|
||||
}),
|
||||
None => HeaderProps::default(),
|
||||
};
|
||||
|
||||
Ok(PostListTemplate {
|
||||
title: "Blog posts".to_owned(),
|
||||
posts,
|
||||
tag,
|
||||
header_props,
|
||||
blog_tags,
|
||||
featured_projects,
|
||||
})
|
||||
}
|
37
src/pages/blog_post_page.rs
Normal file
37
src/pages/blog_post_page.rs
Normal file
@ -0,0 +1,37 @@
|
||||
use askama::Template;
|
||||
use axum::{extract::Path, http::StatusCode};
|
||||
use chrono::{DateTime, Utc};
|
||||
|
||||
use crate::{
|
||||
blog_posts::blog_post_model::BlogPostMetadata, components::site_header::Link, filters,
|
||||
post_utils::post_parser::parse_post,
|
||||
};
|
||||
|
||||
use crate::components::site_header::HeaderProps;
|
||||
|
||||
#[derive(Template)]
|
||||
#[template(path = "blog_post.html")]
|
||||
pub struct BlogPostTemplate {
|
||||
pub title: String,
|
||||
pub body: String,
|
||||
pub date: DateTime<Utc>,
|
||||
pub tags: Vec<String>,
|
||||
pub header_props: HeaderProps,
|
||||
}
|
||||
|
||||
pub async fn render_blog_post(Path(post_id): Path<String>) -> Result<BlogPostTemplate, StatusCode> {
|
||||
let path = format!("../_posts/blog/{}.md", post_id);
|
||||
let parse_post = parse_post::<BlogPostMetadata>(&path, true);
|
||||
let parsed = parse_post.await?;
|
||||
|
||||
Ok(BlogPostTemplate {
|
||||
title: parsed.metadata.title,
|
||||
date: parsed.metadata.date,
|
||||
tags: parsed.metadata.tags,
|
||||
body: parsed.body,
|
||||
header_props: HeaderProps::with_back_link(Link {
|
||||
href: "/blog".to_string(),
|
||||
label: "All posts".to_string(),
|
||||
}),
|
||||
})
|
||||
}
|
78
src/pages/contact.rs
Normal file
78
src/pages/contact.rs
Normal file
@ -0,0 +1,78 @@
|
||||
use askama::Template;
|
||||
use axum::http::StatusCode;
|
||||
|
||||
use crate::components::site_header::HeaderProps;
|
||||
|
||||
pub struct ContactLink {
|
||||
pub href: String,
|
||||
pub title: String,
|
||||
pub label: String,
|
||||
pub svg: String,
|
||||
}
|
||||
|
||||
#[derive(Template)]
|
||||
#[template(path = "contact.html")]
|
||||
pub struct ContactPageTemplate {
|
||||
pub title: String,
|
||||
pub header_props: HeaderProps,
|
||||
pub links: Vec<ContactLink>,
|
||||
}
|
||||
|
||||
pub async fn render_contact() -> Result<ContactPageTemplate, StatusCode> {
|
||||
let links = vec![
|
||||
ContactLink {
|
||||
href: "mailto: michalvankosk@gmail.com".to_string(),
|
||||
label: "michalvankosk@gmail.com".to_string(),
|
||||
title: "E-mail address".to_string(),
|
||||
svg: "mail".to_string(),
|
||||
},
|
||||
ContactLink {
|
||||
href: "https://twitch.tv/michalvankodev".to_string(),
|
||||
label: "Twitch".to_string(),
|
||||
title: "Twitch channel".to_string(),
|
||||
svg: "twitch".to_string(),
|
||||
},
|
||||
ContactLink {
|
||||
href: "https://tiktok.com/@michalvankodev".to_string(),
|
||||
label: "TikTok".to_string(),
|
||||
title: "TikTok channel".to_string(),
|
||||
svg: "tiktok".to_string(),
|
||||
},
|
||||
ContactLink {
|
||||
href: "https://www.youtube.com/@michalvankodev".to_string(),
|
||||
label: "YouTube".to_string(),
|
||||
title: "YouTube channel".to_string(),
|
||||
svg: "youtube".to_string(),
|
||||
},
|
||||
ContactLink {
|
||||
href: "https://instagram.com/michalvankodev".to_string(),
|
||||
label: "Instagram".to_string(),
|
||||
title: "Instagram profile".to_string(),
|
||||
svg: "instagram".to_string(),
|
||||
},
|
||||
ContactLink {
|
||||
href: "https://instagram.com/michalvankodev".to_string(),
|
||||
label: "GitHub".to_string(),
|
||||
title: "Github profile".to_string(),
|
||||
svg: "github".to_string(),
|
||||
},
|
||||
ContactLink {
|
||||
href: "https://www.linkedin.com/in/michal-vanko-dev/".to_string(),
|
||||
label: "LinkedIn".to_string(),
|
||||
title: "LinkedIn profile".to_string(),
|
||||
svg: "linkedin".to_string(),
|
||||
},
|
||||
ContactLink {
|
||||
href: "https://discord.gg/2cGg7kwZEh".to_string(),
|
||||
label: "Discord".to_string(),
|
||||
title: "Discord channel".to_string(),
|
||||
svg: "discord".to_string(),
|
||||
},
|
||||
];
|
||||
|
||||
Ok(ContactPageTemplate {
|
||||
title: "Contact".to_owned(),
|
||||
header_props: HeaderProps::default(),
|
||||
links,
|
||||
})
|
||||
}
|
38
src/pages/index.rs
Normal file
38
src/pages/index.rs
Normal file
@ -0,0 +1,38 @@
|
||||
use askama::Template;
|
||||
use axum::http::StatusCode;
|
||||
use tokio::try_join;
|
||||
|
||||
use crate::{
|
||||
blog_posts::{
|
||||
blog_post_model::BlogPostMetadata, featured_blog_posts::get_featured_blog_posts,
|
||||
tag_list::get_popular_blog_tags,
|
||||
},
|
||||
components::site_header::HeaderProps,
|
||||
filters,
|
||||
post_utils::post_parser::ParseResult,
|
||||
projects::{featured_projects::get_featured_projects, project_model::ProjectMetadata},
|
||||
};
|
||||
|
||||
#[derive(Template)]
|
||||
#[template(path = "index.html")]
|
||||
pub struct IndexTemplate {
|
||||
header_props: HeaderProps,
|
||||
blog_tags: Vec<String>,
|
||||
featured_blog_posts: Vec<ParseResult<BlogPostMetadata>>,
|
||||
featured_projects: Vec<ParseResult<ProjectMetadata>>,
|
||||
}
|
||||
|
||||
pub async fn render_index() -> Result<IndexTemplate, StatusCode> {
|
||||
let (blog_tags, featured_blog_posts, featured_projects) = try_join!(
|
||||
get_popular_blog_tags(),
|
||||
get_featured_blog_posts(),
|
||||
get_featured_projects()
|
||||
)?;
|
||||
|
||||
Ok(IndexTemplate {
|
||||
header_props: HeaderProps::default(),
|
||||
blog_tags,
|
||||
featured_blog_posts,
|
||||
featured_projects,
|
||||
})
|
||||
}
|
6
src/pages/mod.rs
Normal file
6
src/pages/mod.rs
Normal file
@ -0,0 +1,6 @@
|
||||
pub mod admin;
|
||||
pub mod blog_post_list;
|
||||
pub mod blog_post_page;
|
||||
pub mod contact;
|
||||
pub mod index;
|
||||
pub mod project_list;
|
30
src/pages/project_list.rs
Normal file
30
src/pages/project_list.rs
Normal file
@ -0,0 +1,30 @@
|
||||
use askama::Template;
|
||||
use axum::http::StatusCode;
|
||||
|
||||
use crate::{
|
||||
components::site_header::HeaderProps,
|
||||
post_utils::{post_listing::get_post_list, post_parser::ParseResult},
|
||||
projects::project_model::ProjectMetadata,
|
||||
};
|
||||
|
||||
#[derive(Template)]
|
||||
#[template(path = "project_list.html")]
|
||||
pub struct ProjectListTemplate {
|
||||
pub title: String,
|
||||
pub project_list: Vec<ParseResult<ProjectMetadata>>,
|
||||
pub header_props: HeaderProps,
|
||||
}
|
||||
|
||||
pub async fn render_projects_list() -> Result<ProjectListTemplate, StatusCode> {
|
||||
let mut project_list = get_post_list::<ProjectMetadata>("../_projects").await?;
|
||||
|
||||
project_list.sort_by_key(|post| post.slug.to_string());
|
||||
project_list.retain(|project| project.metadata.displayed);
|
||||
project_list.reverse();
|
||||
|
||||
Ok(ProjectListTemplate {
|
||||
title: "Showcase".to_owned(),
|
||||
header_props: HeaderProps::default(),
|
||||
project_list,
|
||||
})
|
||||
}
|
Reference in New Issue
Block a user