This commit is contained in:
10
src/main.rs
10
src/main.rs
@ -84,6 +84,7 @@ fn get_content(config_path: &str) -> (String, String) {
|
||||
fn main() {
|
||||
let configs = fs::read_dir("./laws").expect("No folder with config files");
|
||||
|
||||
let mut li_of_files = String::new();
|
||||
for config in configs {
|
||||
let config = config.unwrap();
|
||||
let filename = config.file_name().into_string().unwrap();
|
||||
@ -93,11 +94,14 @@ fn main() {
|
||||
let path = format!("{}", config.path().display());
|
||||
let (lawname, content) = get_content(&path);
|
||||
|
||||
let template = fs::read_to_string("templates/index.html").unwrap();
|
||||
let template = fs::read_to_string("templates/law.html").unwrap();
|
||||
let site = template
|
||||
.replace("{{content}}", &content)
|
||||
.replace("{{title}}", &lawname);
|
||||
|
||||
li_of_files.push_str(&format!(
|
||||
"<li><a href='./{law_name}'>{lawname}</a></li><br />\n"
|
||||
));
|
||||
fs::write(&format!("output/{law_name}.html"), &site).expect("Unable to write file");
|
||||
}
|
||||
let style = fs::read_to_string("templates/style.css").unwrap();
|
||||
@ -105,4 +109,8 @@ fn main() {
|
||||
|
||||
let style = fs::read_to_string("templates/pico.min.css").unwrap();
|
||||
fs::write(&format!("output/pico.min.css"), &style).expect("Unable to write file");
|
||||
|
||||
let mut index = fs::read_to_string("templates/index.html").unwrap();
|
||||
index = index.replace("{{content}}", &li_of_files);
|
||||
fs::write(&format!("output/index.html"), &index).expect("Unable to write file");
|
||||
}
|
||||
|
Reference in New Issue
Block a user