specify what dirs to create
This commit is contained in:
parent
b1ef76e2de
commit
bfeae64c84
@ -24,13 +24,17 @@ pub fn write_file(html: String) {
|
||||
fs::write("./public/links/index.html", html).expect("Could not write to index.html");
|
||||
}
|
||||
|
||||
pub fn create_dirs() {
|
||||
pub fn create_dirs(dirs: &[&str]) {
|
||||
if !Path::new("./public").exists() {
|
||||
fs::create_dir("./public").expect("Could not create public directory");
|
||||
}
|
||||
if !Path::new("./public/links").exists() {
|
||||
fs::create_dir("./public/links").expect("Could not create public directory");
|
||||
for dir in dirs {
|
||||
let path = format!("./public/{}", dir);
|
||||
if !Path::new(&path).exists() {
|
||||
fs::create_dir(&path).expect("Could not create public directory");
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
pub fn delete_public_dir() {
|
||||
|
@ -4,8 +4,12 @@ use crate::links::{load_links,render_links};
|
||||
|
||||
|
||||
fn main() {
|
||||
// absolutely destroy any /public data, so we have a clean slate to write to
|
||||
file_utils::delete_public_dir();
|
||||
file_utils::create_dirs();
|
||||
file_utils::create_dirs(&[
|
||||
"links",
|
||||
"blog"
|
||||
]);
|
||||
|
||||
// Generate and Write Links
|
||||
let links_input = load_links("data/links/links.yaml");
|
||||
|
Loading…
Reference in New Issue
Block a user