-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
40 changed files
with
163 additions
and
105 deletions.
There are no files selected for viewing
Binary file not shown.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -7,51 +7,62 @@ use axum::{ | |
http::StatusCode | ||
}; | ||
use super::base; | ||
use crate::PageType; | ||
|
||
pub async fn blog_handler(Path(name): Path<String>, State(state): State<SiteState>) -> (StatusCode, Markup) { | ||
if let Some(blog) = get(state.blog.clone(), &name) { | ||
(StatusCode::OK, post(blog, state, true)) | ||
(StatusCode::OK, post(blog, state, PageType::Blog)) | ||
} else { | ||
return not_found().await | ||
} | ||
} | ||
|
||
pub async fn project_handler(Path(name): Path<String>, State(state): State<SiteState>) -> (StatusCode, Markup) { | ||
if let Some(project) = get(state.projects.clone(), &name) { | ||
(StatusCode::OK, post(project, state, false)) | ||
(StatusCode::OK, post(project, state, PageType::Project)) | ||
} else { | ||
not_found().await | ||
} | ||
} | ||
|
||
fn post(post: Post, state: SiteState, is_blog: bool) -> Markup { | ||
let tags = post.tags.iter().map(|x| x.to_string()).collect::<Vec<_>>(); | ||
let mut url = format!("https://ericz.me/blog/{}", post.slug); | ||
if !is_blog { | ||
url = format!("https://ericz.me/projects/{}", post.slug); | ||
pub async fn talk_handler(Path(name): Path<String>, State(state): State<SiteState>) -> (StatusCode, Markup) { | ||
if let Some(talk) = get(state.talks.clone(), &name) { | ||
(StatusCode::OK, post(talk, state, PageType::Talk)) | ||
} else { | ||
not_found().await | ||
} | ||
} | ||
|
||
fn post(post: Post, state: SiteState, page_type: PageType) -> Markup { | ||
let tags = post.tags.iter().map(|x| x.to_string()).collect::<Vec<_>>(); | ||
let page_name = match page_type { | ||
PageType::Blog => "blog", | ||
PageType::Project => "projects", | ||
PageType::Talk => "talks", | ||
}; | ||
|
||
let content = html! { | ||
article class="h-entry" { | ||
h1 class="p-name" { (post.title) }; | ||
div class="byline" { | ||
p { | ||
"by " a class="p-author h-card" href="https://ericz.me" target="_blank" { "Eric" } | ||
@if is_blog { | ||
@if matches!(page_type, PageType::Blog) { | ||
@let date_str = post.date.format("%B %d, %Y").to_string(); | ||
@let date_rfc3339 = post.date.to_rfc3339(); | ||
" on " time class="dt-published" datetime=(date_rfc3339) { (date_str) } | ||
} | ||
br; | ||
"tags: " | ||
@for tag in tags { | ||
a class="p-category" href=(format!("/blog/tags/{}", tag)) { (tag) } " " | ||
a class="p-category" href=(format!("/{}/tags/{}", page_name, tag)) { (tag) } " " | ||
} | ||
} | ||
} | ||
div class="e-content" { | ||
p { (PreEscaped(post.body)) }; | ||
} | ||
a style="display: none;" class="u-url" href=(url) { "Permalink" } | ||
a style="display: none;" class="u-url" href=(format!("https://ericz.me/{}/{}", page_name, post.slug)) { "Permalink" } | ||
} | ||
hr; | ||
p { "If you have any questions, want to change my mind, or literally anything else, please " a href="mailto:[email protected]" {"reach out"} "!" }; | ||
|
Oops, something went wrong.