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()));
+ }
+ }
}