links and some path checks

This commit is contained in:
Tyrel Souza 2023-07-03 00:43:41 -04:00
parent 177c23da42
commit a3cf2380b7
No known key found for this signature in database
GPG Key ID: F3614B02ACBE438E
2 changed files with 6 additions and 3 deletions

View File

@ -107,4 +107,4 @@ links:
links:
- text: Fork this project!
icon: fa-solid fa-code-fork
href: https://github.com/tyrelsouza/lazylinks
href: https://gitea.tyrel.dev/tyrel/rustylinks

View File

@ -50,12 +50,15 @@ fn render_links(rusty_links: RustyLinks) -> String {
tera.render("main.tera", &context).expect("Could not parse")
}
fn write_file(html: String ) {
fn write_file(html: String) {
if Path::new("./output").exists() {
fs::remove_dir_all("./output").expect("could not remove directory");
}
fs::create_dir("./output").expect("Could not create output directory");
copy_recursively("./static", "./output").expect("Could not copy static directory");
// copy all files in static to output
if Path::new("./output").exists() {
copy_recursively("./static", "./output").expect("Could not copy static directory");
}
fs::write("./output/index.html", html).expect("Could not write to index.html");
}