mirror of
https://github.com/zyllian/webdog.git
synced 2025-01-18 03:32:21 -08:00
fix building the site on windows
This commit is contained in:
parent
ecf408d796
commit
e770a9bd8d
2 changed files with 9 additions and 8 deletions
10
src/lib.rs
10
src/lib.rs
|
@ -15,6 +15,7 @@ use std::{
|
|||
|
||||
use anyhow::Context;
|
||||
use serde::Deserialize;
|
||||
use serving::get_name;
|
||||
use url::Url;
|
||||
use walkdir::WalkDir;
|
||||
|
||||
|
@ -100,14 +101,11 @@ impl Site {
|
|||
|
||||
if let Some(ext) = path.extension() {
|
||||
if ext == "hbs" && entry.file_type().is_file() {
|
||||
template_index.insert(
|
||||
let (_, name) = get_name(
|
||||
path.strip_prefix(&templates_path)
|
||||
.context("This really shouldn't have happened")?
|
||||
.with_extension("")
|
||||
.to_string_lossy()
|
||||
.to_string(),
|
||||
path.to_owned(),
|
||||
.context("This really shouldn't have happened")?,
|
||||
);
|
||||
template_index.insert(name, path.to_owned());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -27,9 +27,12 @@ fn with_build_path(
|
|||
}
|
||||
|
||||
/// Helper to get the "name" of a path.
|
||||
fn get_name(path: &Path) -> (PathBuf, String) {
|
||||
pub fn get_name(path: &Path) -> (PathBuf, String) {
|
||||
let name = path.with_extension("");
|
||||
let name_str = name.display().to_string();
|
||||
let name_str = name
|
||||
.display()
|
||||
.to_string()
|
||||
.replace(std::path::MAIN_SEPARATOR, "/");
|
||||
(name, name_str)
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue