~/website

0f8635bccb99309ada9e6ceb10666a1eee645774 — arthurmelton adbb0061 2 years ago
move static to public
2 files changed, 19 insertions(+), 1 deletions(-)

M .gitignore
M src/main.rs
M .gitignore => .gitignore +7 -0
@@ 1,1 1,8 @@

/target

/public
/static
/blogs
/pages
template.html.hbs
blog.html.hbs

M src/main.rs => src/main.rs +12 -1
@@ 1,3 1,14 @@

use walkdir::WalkDir;
use std::fs;
use std::path::Path;

fn main() {
    println!("Hello, world!");
    let _ = fs::create_dir("public");
    for e in WalkDir::new("static").into_iter().filter_map(|e| e.ok()) {
        if e.metadata().unwrap().is_file() {
            let mut path = e.path();
            path = path.strip_prefix("static/").unwrap(); // should never fail
            fs::copy(e.path(), Path::new("public").join(path)).expect(&format!("failed to copy static/{} to public/{}", path.display(), path.display()));
        }
    }
}