mirror of
https://github.com/zyllian/zyllian.github.io.git
synced 2025-05-09 18:16:43 -07:00
fix builds without serve feature
This commit is contained in:
parent
4e624a3afa
commit
9285fc0974
3 changed files with 13 additions and 13 deletions
|
@ -15,8 +15,8 @@ use std::{
|
||||||
|
|
||||||
use eyre::Context;
|
use eyre::Context;
|
||||||
use serde::Deserialize;
|
use serde::Deserialize;
|
||||||
use serving::get_name;
|
|
||||||
use url::Url;
|
use url::Url;
|
||||||
|
use util::get_name;
|
||||||
use walkdir::WalkDir;
|
use walkdir::WalkDir;
|
||||||
|
|
||||||
use builder::SiteBuilder;
|
use builder::SiteBuilder;
|
||||||
|
|
|
@ -18,7 +18,7 @@ use warp::{
|
||||||
Filter,
|
Filter,
|
||||||
};
|
};
|
||||||
|
|
||||||
use crate::{Site, SiteBuilder, PAGES_PATH, ROOT_PATH, SASS_PATH, TEMPLATES_PATH};
|
use crate::{util::get_name, Site, SiteBuilder, PAGES_PATH, ROOT_PATH, SASS_PATH, TEMPLATES_PATH};
|
||||||
|
|
||||||
fn with_build_path(
|
fn with_build_path(
|
||||||
build_path: PathBuf,
|
build_path: PathBuf,
|
||||||
|
@ -26,16 +26,6 @@ fn with_build_path(
|
||||||
warp::any().map(move || build_path.clone())
|
warp::any().map(move || build_path.clone())
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Helper to get the "name" of a path.
|
|
||||||
pub fn get_name(path: &Path) -> (PathBuf, String) {
|
|
||||||
let name = path.with_extension("");
|
|
||||||
let name_str = name
|
|
||||||
.display()
|
|
||||||
.to_string()
|
|
||||||
.replace(std::path::MAIN_SEPARATOR, "/");
|
|
||||||
(name, name_str)
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Helper to make a path relative.
|
/// Helper to make a path relative.
|
||||||
fn rel(path: &Path, prefix: &Path) -> Result<PathBuf, std::path::StripPrefixError> {
|
fn rel(path: &Path, prefix: &Path) -> Result<PathBuf, std::path::StripPrefixError> {
|
||||||
Ok(path.strip_prefix(prefix)?.to_owned())
|
Ok(path.strip_prefix(prefix)?.to_owned())
|
||||||
|
|
12
src/util.rs
12
src/util.rs
|
@ -1,6 +1,6 @@
|
||||||
//! Module containing various utilities.
|
//! Module containing various utilities.
|
||||||
|
|
||||||
use std::path::Path;
|
use std::path::{Path, PathBuf};
|
||||||
|
|
||||||
/// Simple helper to remove the contents of a directory without removing the directory itself.
|
/// Simple helper to remove the contents of a directory without removing the directory itself.
|
||||||
pub fn remove_dir_contents(path: &Path) -> eyre::Result<()> {
|
pub fn remove_dir_contents(path: &Path) -> eyre::Result<()> {
|
||||||
|
@ -16,3 +16,13 @@ pub fn remove_dir_contents(path: &Path) -> eyre::Result<()> {
|
||||||
|
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Helper to get the "name" of a path.
|
||||||
|
pub fn get_name(path: &Path) -> (PathBuf, String) {
|
||||||
|
let name = path.with_extension("");
|
||||||
|
let name_str = name
|
||||||
|
.display()
|
||||||
|
.to_string()
|
||||||
|
.replace(std::path::MAIN_SEPARATOR, "/");
|
||||||
|
(name, name_str)
|
||||||
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue