mylloon.fr/src/routes/index.rs
Mylloon 49af05a565
All checks were successful
ci/woodpecker/push/publish Pipeline was successful
add content type, allowing firefox to see source code of pages
2023-10-24 13:27:02 +02:00

43 lines
1,008 B
Rust

use actix_web::{get, web, Responder};
use cached::proc_macro::once;
use ramhorns::Content;
use crate::{
config::Config,
misc::utils::{make_kw, Html},
template::{Infos, NavBar},
};
#[get("/")]
async fn page(config: web::Data<Config>) -> impl Responder {
Html(build_page(config.get_ref().to_owned()))
}
#[derive(Content, Debug)]
struct IndexTemplate {
navbar: NavBar,
fullname: String,
}
#[once(time = 60)]
fn build_page(config: Config) -> String {
config.tmpl.render(
"index.html",
IndexTemplate {
navbar: NavBar {
index: true,
..NavBar::default()
},
fullname: config
.fc
.fullname
.to_owned()
.unwrap_or("Fullname".to_owned()),
},
Infos {
page_title: config.fc.fullname,
page_desc: Some("Page principale".into()),
page_kw: make_kw(&["index", "étudiant"]),
},
)
}