From dfe1d9f263d7fc09a5f46bddcebaa7447342043a Mon Sep 17 00:00:00 2001 From: Mylloon Date: Thu, 14 Sep 2023 23:50:21 +0200 Subject: [PATCH] Add bold --- src/routes/index.rs | 19 +++++++++++++++++-- src/template.rs | 10 ++++++++++ static/css/style.css | 4 ++++ templates/navbar.html | 27 ++++++++++++++++++++++----- 4 files changed, 53 insertions(+), 7 deletions(-) diff --git a/src/routes/index.rs b/src/routes/index.rs index e09e85b..b6707a5 100644 --- a/src/routes/index.rs +++ b/src/routes/index.rs @@ -1,7 +1,12 @@ use actix_web::{get, web, HttpRequest, HttpResponse, Responder}; use cached::proc_macro::once; +use ramhorns::Content; -use crate::{config::Config, misc::utils::get_url, template::Infos}; +use crate::{ + config::Config, + misc::utils::get_url, + template::{Infos, NavBar}, +}; #[get("/")] pub async fn page(req: HttpRequest, config: web::Data) -> impl Responder { @@ -11,11 +16,21 @@ pub async fn page(req: HttpRequest, config: web::Data) -> impl Responder )) } +#[derive(Content, Debug)] +struct IndexTemplate { + navbar: NavBar, +} + #[once(time = 60)] pub fn build_page(config: Config, url: String) -> String { config.tmpl.render( "index.html", - (), + IndexTemplate { + navbar: NavBar { + index: true, + ..NavBar::default() + }, + }, Infos { page_title: config.fc.fullname, page_desc: Some("Page principale".into()), diff --git a/src/template.rs b/src/template.rs index c0bc404..14f8341 100644 --- a/src/template.rs +++ b/src/template.rs @@ -22,6 +22,16 @@ pub struct Infos { pub url: String, } +#[derive(Content, Debug, Default)] +pub struct NavBar { + pub index: bool, + pub blog: bool, + pub portfolio: bool, + pub networks: bool, + pub contrib: bool, + pub cours: bool, +} + /// Final structure given to template #[derive(Content, Debug)] struct Data { diff --git a/static/css/style.css b/static/css/style.css index d4cda74..a974097 100644 --- a/static/css/style.css +++ b/static/css/style.css @@ -10,3 +10,7 @@ .navbar li:last-child p::after { content: ""; } + +.bold { + font-weight: bold; +} diff --git a/templates/navbar.html b/templates/navbar.html index 81640ba..63c5048 100644 --- a/templates/navbar.html +++ b/templates/navbar.html @@ -1,19 +1,36 @@ +{{#data}}{{#navbar}} +{{/navbar}}{{/data}}