This commit is contained in:
parent
1ce8ccfdd5
commit
da78b80587
7
justfile
7
justfile
@ -5,18 +5,15 @@ tailwind:
|
|||||||
npx tailwindcss -i ./styles/input.css -o ./styles/output.css --watch
|
npx tailwindcss -i ./styles/input.css -o ./styles/output.css --watch
|
||||||
|
|
||||||
# svg sprite creation
|
# svg sprite creation
|
||||||
# TODO change route on svetle project deletion
|
|
||||||
# TODO #directory-swap
|
|
||||||
svgstore:
|
svgstore:
|
||||||
npx svgstore -o templates/icons/sprite.svg ../src/svg/**.svg
|
npx svgstore -o templates/icons/sprite.svg src/svg/**.svg
|
||||||
|
|
||||||
server_dev:
|
server_dev:
|
||||||
cargo watch -x run
|
cargo watch -x run
|
||||||
|
|
||||||
# CMS server for local dev
|
# CMS server for local dev
|
||||||
# TODO #directory-swap
|
|
||||||
decap_server:
|
decap_server:
|
||||||
cd .. && npx decap-server
|
npx decap-server
|
||||||
|
|
||||||
# Run dev server in watch mode
|
# Run dev server in watch mode
|
||||||
dev:
|
dev:
|
||||||
|
@ -3,7 +3,7 @@ use serde::Deserialize;
|
|||||||
|
|
||||||
use crate::post_utils::post_parser::deserialize_date;
|
use crate::post_utils::post_parser::deserialize_date;
|
||||||
|
|
||||||
pub const BLOG_POST_PATH: &str = "../_posts/blog";
|
pub const BLOG_POST_PATH: &str = "_posts/blog";
|
||||||
|
|
||||||
#[derive(Deserialize, Debug)]
|
#[derive(Deserialize, Debug)]
|
||||||
pub struct BlogPostMetadata {
|
pub struct BlogPostMetadata {
|
||||||
|
14
src/main.rs
14
src/main.rs
@ -31,15 +31,11 @@ async fn main() {
|
|||||||
// build our application with a single route
|
// build our application with a single route
|
||||||
let app = router::get_router()
|
let app = router::get_router()
|
||||||
.nest_service("/styles", ServeDir::new("styles"))
|
.nest_service("/styles", ServeDir::new("styles"))
|
||||||
.nest_service("/images", ServeDir::new("../static/images"))
|
.nest_service("/images", ServeDir::new("static/images"))
|
||||||
.nest_service("/fonts", ServeDir::new("../static/fonts"))
|
.nest_service("/fonts", ServeDir::new("static/fonts"))
|
||||||
.nest_service("/generated_images", ServeDir::new("generated_images"))
|
.nest_service("/generated_images", ServeDir::new("generated_images"))
|
||||||
.nest_service("/svg", ServeDir::new("../static/svg"))
|
.nest_service("/svg", ServeDir::new("static/svg"))
|
||||||
// TODO manifest logos have bad link, #directory-swap
|
.nest_service("/config.yml", ServeDir::new("static/resources/config.yml")); // Decap CMS config
|
||||||
.nest_service(
|
|
||||||
"/config.yml",
|
|
||||||
ServeDir::new("../static/resources/config.yml"),
|
|
||||||
);
|
|
||||||
|
|
||||||
#[cfg(debug_assertions)]
|
#[cfg(debug_assertions)]
|
||||||
let app = app.layer(LiveReloadLayer::new());
|
let app = app.layer(LiveReloadLayer::new());
|
||||||
@ -59,6 +55,4 @@ async fn main() {
|
|||||||
// THINK deploy to alula? rather then katelyn? can be change whenever
|
// THINK deploy to alula? rather then katelyn? can be change whenever
|
||||||
// TODO after release
|
// TODO after release
|
||||||
// OG tags
|
// OG tags
|
||||||
// Remove old web completely
|
|
||||||
// Restructure repository
|
|
||||||
// - projects page
|
// - projects page
|
||||||
|
@ -2,6 +2,7 @@ use askama::Template;
|
|||||||
use axum::{extract::Path, http::StatusCode};
|
use axum::{extract::Path, http::StatusCode};
|
||||||
use chrono::{DateTime, Utc};
|
use chrono::{DateTime, Utc};
|
||||||
|
|
||||||
|
use crate::blog_posts::blog_post_model::BLOG_POST_PATH;
|
||||||
use crate::{
|
use crate::{
|
||||||
blog_posts::blog_post_model::BlogPostMetadata, components::site_header::Link, filters,
|
blog_posts::blog_post_model::BlogPostMetadata, components::site_header::Link, filters,
|
||||||
post_utils::post_parser::parse_post,
|
post_utils::post_parser::parse_post,
|
||||||
@ -20,7 +21,7 @@ pub struct BlogPostTemplate {
|
|||||||
}
|
}
|
||||||
|
|
||||||
pub async fn render_blog_post(Path(post_id): Path<String>) -> Result<BlogPostTemplate, StatusCode> {
|
pub async fn render_blog_post(Path(post_id): Path<String>) -> Result<BlogPostTemplate, StatusCode> {
|
||||||
let path = format!("../_posts/blog/{}.md", post_id);
|
let path = format!("{}/{}.md", BLOG_POST_PATH, post_id);
|
||||||
let parse_post = parse_post::<BlogPostMetadata>(&path, true);
|
let parse_post = parse_post::<BlogPostMetadata>(&path, true);
|
||||||
let parsed = parse_post.await?;
|
let parsed = parse_post.await?;
|
||||||
|
|
||||||
|
@ -16,7 +16,7 @@ pub struct ProjectListTemplate {
|
|||||||
}
|
}
|
||||||
|
|
||||||
pub async fn render_projects_list() -> Result<ProjectListTemplate, StatusCode> {
|
pub async fn render_projects_list() -> Result<ProjectListTemplate, StatusCode> {
|
||||||
let mut project_list = get_post_list::<ProjectMetadata>("../_projects").await?;
|
let mut project_list = get_post_list::<ProjectMetadata>("_projects").await?;
|
||||||
|
|
||||||
project_list.sort_by_key(|post| post.slug.to_string());
|
project_list.sort_by_key(|post| post.slug.to_string());
|
||||||
project_list.retain(|project| project.metadata.displayed);
|
project_list.retain(|project| project.metadata.displayed);
|
||||||
|
@ -42,9 +42,8 @@ pub fn generate_picture_markup(
|
|||||||
}
|
}
|
||||||
let path_to_generated = get_generated_file_name(orig_img_path);
|
let path_to_generated = get_generated_file_name(orig_img_path);
|
||||||
|
|
||||||
// TODO This should get removed when we move the project structure #directory-swap
|
|
||||||
let disk_img_path =
|
let disk_img_path =
|
||||||
Path::new("../static/").join(orig_img_path.strip_prefix("/").unwrap_or(orig_img_path));
|
Path::new("static/").join(orig_img_path.strip_prefix("/").unwrap_or(orig_img_path));
|
||||||
|
|
||||||
let orig_img_dimensions = image_dimensions(&disk_img_path)?;
|
let orig_img_dimensions = image_dimensions(&disk_img_path)?;
|
||||||
let resolutions = get_resolutions(orig_img_dimensions, width, height);
|
let resolutions = get_resolutions(orig_img_dimensions, width, height);
|
||||||
|
@ -8,7 +8,6 @@ use super::post_parser::{parse_post, ParseResult};
|
|||||||
pub async fn get_post_list<'de, Metadata: DeserializeOwned>(
|
pub async fn get_post_list<'de, Metadata: DeserializeOwned>(
|
||||||
path: &str,
|
path: &str,
|
||||||
) -> Result<Vec<ParseResult<Metadata>>, StatusCode> {
|
) -> Result<Vec<ParseResult<Metadata>>, StatusCode> {
|
||||||
// let path = "../_posts/blog/";
|
|
||||||
let mut dir = read_dir(path)
|
let mut dir = read_dir(path)
|
||||||
.await
|
.await
|
||||||
.map_err(|_| StatusCode::INTERNAL_SERVER_ERROR)?;
|
.map_err(|_| StatusCode::INTERNAL_SERVER_ERROR)?;
|
||||||
|
@ -117,7 +117,7 @@ pub fn parse_html(markdown: &str, generate_images: bool) -> String {
|
|||||||
}
|
}
|
||||||
|
|
||||||
let dev_only_img_path =
|
let dev_only_img_path =
|
||||||
Path::new("../static/").join(dest_url.strip_prefix("/").unwrap_or(&dest_url));
|
Path::new("static/").join(dest_url.strip_prefix("/").unwrap_or(&dest_url));
|
||||||
let img_dimensions = image_dimensions(&dev_only_img_path).unwrap();
|
let img_dimensions = image_dimensions(&dev_only_img_path).unwrap();
|
||||||
|
|
||||||
let (max_width, max_height) = get_max_resolution(
|
let (max_width, max_height) = get_max_resolution(
|
||||||
|
@ -5,7 +5,7 @@ use crate::post_utils::{post_listing::get_post_list, post_parser::ParseResult};
|
|||||||
use super::project_model::ProjectMetadata;
|
use super::project_model::ProjectMetadata;
|
||||||
|
|
||||||
pub async fn get_featured_projects() -> Result<Vec<ParseResult<ProjectMetadata>>, StatusCode> {
|
pub async fn get_featured_projects() -> Result<Vec<ParseResult<ProjectMetadata>>, StatusCode> {
|
||||||
let project_list = get_post_list::<ProjectMetadata>("../_projects").await?;
|
let project_list = get_post_list::<ProjectMetadata>("_projects").await?;
|
||||||
|
|
||||||
let featured_projects = project_list
|
let featured_projects = project_list
|
||||||
.into_iter()
|
.into_iter()
|
||||||
|
Loading…
Reference in New Issue
Block a user