31 lines
717 B
Rust
31 lines
717 B
Rust
//! Public landing page.
|
|
|
|
use axum_extra::extract::cookie::CookieJar;
|
|
use loco_rs::prelude::*;
|
|
use serde_json::json;
|
|
|
|
use crate::{controllers::i18n::current_lang, shared::guard, controllers::shop};
|
|
|
|
#[debug_handler]
|
|
async fn index(
|
|
jar: CookieJar,
|
|
ViewEngine(v): ViewEngine<TeraView>,
|
|
State(ctx): State<AppContext>,
|
|
) -> Result<Response> {
|
|
let products = shop::featured_products(&ctx, 8).await?;
|
|
|
|
format::view(
|
|
&v,
|
|
"home/index.html",
|
|
json!({
|
|
"products": products,
|
|
"logged_in_admin": guard::logged_in(&ctx, &jar).await,
|
|
"lang": current_lang(&jar),
|
|
}),
|
|
)
|
|
}
|
|
|
|
pub fn routes() -> Routes {
|
|
Routes::new().add("/", get(index))
|
|
}
|