feat: markdown implementation #18

Merged
Anri merged 9 commits from feat/md into main 2023-04-11 01:25:45 +02:00
2 changed files with 13 additions and 2 deletions
Showing only changes of commit 46ced07b2a - Show all commits

View file

@ -86,10 +86,11 @@ pub fn get_config(file_path: &str) -> Config {
); );
Config { Config {
fc: internal_config, fc: internal_config.clone(),
static_location: format!("{}/{}", files_root, static_dir), static_location: format!("{}/{}", files_root, static_dir),
tmpl: Template { tmpl: Template {
directory: format!("{}/{}", files_root, templates_dir), directory: format!("{}/{}", files_root, templates_dir),
app_name: internal_config.app_name.unwrap(),
}, },
} }
} }

View file

@ -4,6 +4,13 @@ use serde::Deserialize;
#[derive(Clone)] #[derive(Clone)]
pub struct Template { pub struct Template {
pub directory: String, pub directory: String,
pub app_name: String,
}
#[derive(Content)]
struct Data<T> {
app_name: String,
data: T,
} }
impl Template { impl Template {
@ -11,7 +18,10 @@ impl Template {
let mut templates: Ramhorns = Ramhorns::lazy(&self.directory).unwrap(); let mut templates: Ramhorns = Ramhorns::lazy(&self.directory).unwrap();
let tplt = templates.from_file(template).unwrap(); let tplt = templates.from_file(template).unwrap();
tplt.render(&data) tplt.render(&Data {
app_name: self.app_name.clone(),
data,
})
} }
} }