Responsive design for index and blog listing page
This commit is contained in:
@ -8,10 +8,10 @@ pub fn pretty_date(date_time: &DateTime<Utc>) -> ::askama::Result<String> {
|
||||
}
|
||||
|
||||
// This filter does not have extra arguments
|
||||
pub fn description_filter(body: &String) -> ::askama::Result<String> {
|
||||
pub fn description_filter(body: &str) -> ::askama::Result<String> {
|
||||
let description = body
|
||||
.lines()
|
||||
.filter(|line| line.starts_with("<p"))
|
||||
.filter(|line| line.starts_with("<p>"))
|
||||
.take(2)
|
||||
.collect::<Vec<&str>>()
|
||||
.join("\n");
|
||||
|
@ -49,5 +49,7 @@ async fn main() {
|
||||
}
|
||||
|
||||
// TODO responsive design
|
||||
// - contact
|
||||
// TODO Fix header menu link on blog
|
||||
// TODO Colors
|
||||
// TODO go live pipeline
|
||||
|
@ -1,20 +1,27 @@
|
||||
use askama::Template;
|
||||
use axum::{extract::Path, http::StatusCode};
|
||||
use tokio::try_join;
|
||||
|
||||
use crate::{
|
||||
blog_posts::blog_post_model::{BlogPostMetadata, BLOG_POST_PATH},
|
||||
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 = "post_list.html")]
|
||||
#[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(
|
||||
@ -23,7 +30,12 @@ pub async fn render_blog_post_list(
|
||||
// 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 mut post_list = get_post_list::<BlogPostMetadata>(BLOG_POST_PATH).await?;
|
||||
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();
|
||||
@ -56,5 +68,7 @@ pub async fn render_blog_post_list(
|
||||
posts,
|
||||
tag,
|
||||
header_props,
|
||||
blog_tags,
|
||||
featured_projects,
|
||||
})
|
||||
}
|
||||
|
@ -27,7 +27,7 @@ pub fn generate_picture_markup(
|
||||
let dev_only_img_path =
|
||||
Path::new("../static/").join(orig_img_path.strip_prefix("/").unwrap_or(orig_img_path));
|
||||
|
||||
let orig_img_dimensions = image_dimensions(&dev_only_img_path).unwrap();
|
||||
let orig_img_dimensions = image_dimensions(&dev_only_img_path)?;
|
||||
let resolutions = get_resolutions(orig_img_dimensions, width, height);
|
||||
|
||||
let path_to_generated_arc = Arc::new(path_to_generated);
|
||||
|
@ -163,9 +163,6 @@ pub fn parse_html(markdown: &str, generate_images: bool) -> String {
|
||||
let syntax_reference = syntax_set
|
||||
.find_syntax_by_token(lang)
|
||||
.unwrap_or(syntax_set.find_syntax_plain_text());
|
||||
syntax_set.syntaxes().iter().for_each(|sr| {
|
||||
debug!("{}", sr.name);
|
||||
});
|
||||
let highlighted =
|
||||
highlighted_html_for_string(&text, &syntax_set, syntax_reference, theme)
|
||||
.unwrap();
|
||||
|
Reference in New Issue
Block a user