implement support for directories in the static file structure

This commit is contained in:
zyl 2024-06-14 22:01:05 -07:00
parent d07eab6f37
commit 4d1d5308d3
No known key found for this signature in database
GPG key ID: FDAEE0976A45AAC3

View file

@ -95,10 +95,16 @@ impl<'a> SiteBuilder<'a> {
let root_path = self.site.site_path.join(ROOT_PATH);
if root_path.exists() {
for entry in root_path.read_dir()? {
for entry in walkdir::WalkDir::new(&root_path) {
let entry = entry?;
let path = entry.path();
std::fs::copy(&path, self.build_path.join(path.strip_prefix(&root_path)?))?;
if path.is_dir() {
continue;
}
let output_path = self.build_path.join(path.strip_prefix(&root_path)?);
let parent_path = output_path.parent().expect("should never fail");
std::fs::create_dir_all(parent_path)?;
std::fs::copy(path, output_path)?;
}
}