feat: allow subdirs in posts directory #86

Merged
Anri merged 4 commits from posts-subdir into main 2024-11-14 17:48:08 +01:00
5 changed files with 7 additions and 22 deletions
Showing only changes of commit 6c16315a07 - Show all commits

View file

@ -13,8 +13,8 @@ use crate::routes::{
mod config; mod config;
mod template; mod template;
mod utils;
mod routes; mod routes;
mod utils;
#[actix_web::main] #[actix_web::main]
async fn main() -> Result<()> { async fn main() -> Result<()> {

View file

@ -1,4 +1,4 @@
use crate::{config::Config, utils::misc::get_url, template::InfosPage}; use crate::{config::Config, template::InfosPage, utils::misc::get_url};
use actix_web::{get, http::header::ContentType, routes, web, HttpResponse, Responder}; use actix_web::{get, http::header::ContentType, routes, web, HttpResponse, Responder};
use cached::proc_macro::once; use cached::proc_macro::once;
use ramhorns::Content; use ramhorns::Content;

View file

@ -4,8 +4,8 @@ use ramhorns::Content;
use crate::{ use crate::{
config::Config, config::Config,
utils::misc::{get_url, Html},
template::{InfosPage, NavBar}, template::{InfosPage, NavBar},
utils::misc::{get_url, Html},
}; };
pub async fn page(config: web::Data<Config>) -> impl Responder { pub async fn page(config: web::Data<Config>) -> impl Responder {

View file

@ -36,21 +36,12 @@ fn build_page(config: Config) -> String {
let ext = ".md"; let ext = ".md";
// Get about // Get about
let about = read_file( let about = read_file(format!("{projects_dir}/about.md"), MType::Generic);
format!("{projects_dir}/about.md"),
MType::Generic,
);
// Get apps // Get apps
let apps = glob(&format!("{apps_dir}/*{ext}")) let apps = glob(&format!("{apps_dir}/*{ext}"))
.unwrap() .unwrap()
.map(|e| { .map(|e| read_file(e.unwrap().to_string_lossy().to_string(), MType::Portfolio).unwrap())
read_file(
e.unwrap().to_string_lossy().to_string(),
MType::Portfolio,
)
.unwrap()
})
.collect::<Vec<File>>(); .collect::<Vec<File>>();
let appdata = if apps.is_empty() { let appdata = if apps.is_empty() {
@ -62,13 +53,7 @@ fn build_page(config: Config) -> String {
// Get archived apps // Get archived apps
let archived_apps = glob(&format!("{apps_dir}/archive/*{ext}")) let archived_apps = glob(&format!("{apps_dir}/archive/*{ext}"))
.unwrap() .unwrap()
.map(|e| { .map(|e| read_file(e.unwrap().to_string_lossy().to_string(), MType::Portfolio).unwrap())
read_file(
e.unwrap().to_string_lossy().to_string(),
MType::Portfolio,
)
.unwrap()
})
.collect::<Vec<File>>(); .collect::<Vec<File>>();
let archived_appdata = if archived_apps.is_empty() { let archived_appdata = if archived_apps.is_empty() {

View file

@ -3,8 +3,8 @@ use cached::proc_macro::once;
use crate::{ use crate::{
config::Config, config::Config,
utils::misc::{make_kw, Html},
template::InfosPage, template::InfosPage,
utils::misc::{make_kw, Html},
}; };
#[get("/web3")] #[get("/web3")]