X-Git-Url: https://git.r.bdr.sh/rbdr/blog/blobdiff_plain/2998247083406f914b3647cedd19abf5507bf2c6..5c7a9258a11d387f33209e07ca7d3271ba8e2a06:/src/generator/static_files.rs?ds=inline 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) }