All checks were successful
CI/CD Pipeline / deploy-main (push) Successful in 5m34s
35 lines
927 B
Rust
35 lines
927 B
Rust
use std::{fs, path::Path};
|
|
|
|
mod law;
|
|
|
|
fn main() {
|
|
fs::create_dir_all("./output").unwrap();
|
|
|
|
let overview = law::create_law_files();
|
|
create_static_files();
|
|
|
|
create_index(&overview);
|
|
}
|
|
|
|
/// Creates the `index.html` file.
|
|
fn create_index(content: &str) {
|
|
let mut index = fs::read_to_string("templates/index.html").unwrap();
|
|
index = index.replace("{{content}}", content);
|
|
fs::write("output/index.html", &index).expect("Unable to write file");
|
|
}
|
|
|
|
/// Copies all files from `templates/static` to `output`
|
|
fn create_static_files() {
|
|
let from = Path::new("templates/static");
|
|
let to = Path::new("output");
|
|
|
|
for entry in fs::read_dir(from).expect("No templates/static folder") {
|
|
let entry = entry.unwrap();
|
|
let path = entry.path();
|
|
if path.is_file() {
|
|
let to_path = to.join(entry.file_name());
|
|
fs::copy(&path, &to_path).unwrap();
|
|
}
|
|
}
|
|
}
|