generated from alecodes/base-template
wip: change assets handling to vite-rs
This commit is contained in:
parent
6cf98d1f1a
commit
adbade7411
26 changed files with 761 additions and 112 deletions
23
src/lib.rs
23
src/lib.rs
|
|
@ -1,34 +1,23 @@
|
|||
pub mod static_assets;
|
||||
pub mod config;
|
||||
mod error;
|
||||
pub mod router;
|
||||
|
||||
use crate::static_assets::Assets;
|
||||
use axum::extract::FromRef;
|
||||
pub use error::{Error, Result, ResultTemplate};
|
||||
use minijinja::{Environment, Template};
|
||||
use serde::{Deserialize, Serialize};
|
||||
|
||||
pub type Tx = axum_sqlx_tx::Tx<sqlx::Postgres>;
|
||||
pub type TxState = axum_sqlx_tx::State<sqlx::Postgres>;
|
||||
|
||||
#[derive(Serialize, Deserialize, Debug)]
|
||||
pub struct Link {
|
||||
pub path: String,
|
||||
pub text: String,
|
||||
pub subpages: Vec<Self>,
|
||||
}
|
||||
|
||||
#[derive(Clone, FromRef)]
|
||||
pub struct AppState {
|
||||
tmpl_env: Environment<'static>,
|
||||
tx: TxState,
|
||||
pub assets: Assets,
|
||||
pub tx: TxState,
|
||||
}
|
||||
|
||||
impl AppState {
|
||||
pub fn new(tmpl_env: Environment<'static>, tx: TxState) -> Self {
|
||||
AppState { tmpl_env, tx }
|
||||
}
|
||||
|
||||
pub fn get_template(&self, name: &str) -> Result<Template> {
|
||||
Ok(self.tmpl_env.get_template(name)?)
|
||||
pub fn new(assets: Assets, tx: TxState) -> Self {
|
||||
AppState { assets, tx }
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue