X-Git-Url: https://git.r.bdr.sh/rbdr/blog/blobdiff_plain/2998247083406f914b3647cedd19abf5507bf2c6..898192d46a0012f77f07afba7145b96d734a707c:/src/generator/static_files.rs diff --git a/src/generator/static_files.rs b/src/generator/static_files.rs index 6804800..401eacf 100644 --- a/src/generator/static_files.rs +++ b/src/generator/static_files.rs @@ -1,29 +1,9 @@ -use std::fs::{copy, create_dir_all, read_dir}; use std::io::Result; use std::path::PathBuf; -use crate::post::Post; +use crate::template::TemplateContext; +use crate::utils::recursively_copy; -fn recursively_copy(source: &PathBuf, target: &PathBuf) -> Result<()> { - let entries = read_dir(source)?; - for entry in entries { - let entry = entry?; - let entry_type = entry.file_type()?; - let entry_name = entry.file_name(); - let entry_source = entry.path(); - let entry_target = target.join(entry_name); - - if entry_type.is_dir() { - create_dir_all(&entry_target)?; - recursively_copy(&entry_source, &entry_target)?; - } else { - copy(&entry_source, &entry_target)?; - } - } - - Ok(()) -} - -pub fn generate(source: &PathBuf, _: &PathBuf, target: &PathBuf, _: &Vec) -> Result<()> { +pub fn generate(source: &PathBuf, _: &PathBuf, target: &PathBuf, _: &TemplateContext) -> Result<()> { if source.exists() { return recursively_copy(source, target) }