From a3cf2380b7453613f4816141fc5791baf44799a5 Mon Sep 17 00:00:00 2001 From: Tyrel Souza Date: Mon, 3 Jul 2023 00:43:41 -0400 Subject: [PATCH] links and some path checks --- links.yaml | 2 +- src/main.rs | 7 +++++-- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/links.yaml b/links.yaml index 93e98c9..a137053 100644 --- a/links.yaml +++ b/links.yaml @@ -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 diff --git a/src/main.rs b/src/main.rs index 0cb730c..4dffe25 100644 --- a/src/main.rs +++ b/src/main.rs @@ -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"); }