Skip to main content

prepare_serve_dir

Function prepare_serve_dir 

Source
pub fn prepare_serve_dir(
    paths: &Paths,
    serve_dir: &PathBuf,
) -> Result<(), SsgError>
Expand description

Prepares the serve directory by creating it and copying site files.

ยงExamples

use ssg::{Paths, server::prepare_serve_dir};
use std::path::PathBuf;
use tempfile::tempdir;
use std::fs;

let dir = tempdir().unwrap();
let site = dir.path().join("site");
let serve = dir.path().join("serve");
fs::create_dir(&site).unwrap();
fs::write(site.join("a.html"), "<p>").unwrap();
let paths = Paths {
    site,
    content: PathBuf::from("content"),
    build: PathBuf::from("build"),
    template: PathBuf::from("templates"),
};
prepare_serve_dir(&paths, &serve).unwrap();
assert!(serve.join("a.html").exists());