refactor: re-structure frontend code

This commit is contained in:
Alexander Navarro 2025-02-19 12:44:09 -03:00
parent 6b7642b693
commit 3e0dd79217
11 changed files with 101 additions and 7 deletions

View file

@ -1,7 +1,7 @@
#![allow(unused)]
#![allow(dead_code)]
use compendium::{router, AppState, Link, Result};
use compendium::{router, AppState, Error, Link, Result};
use minijinja::{Environment, Value};
use std::sync::Arc;
use tower_http::trace::TraceLayer;
@ -12,7 +12,16 @@ fn load_templates() -> Result<Environment<'static>> {
let mut tmpl_env = Environment::new();
#[cfg(debug_assertions)]
tmpl_env.set_loader(minijinja::path_loader("templates")); // Path is relative to project root
{
tmpl_env.set_loader(minijinja::path_loader("dist")); // Path is relative to project root
let _ = tmpl_env.get_template("base.html");
if tmpl_env.templates().count() == 0 {
return Err(Error::Runtime(
"Templates not found, did you build the frontend with `just build-frontend`??",
));
}
}
// only enable in production build
#[cfg(not(debug_assertions))]