Compare commits
No commits in common. "b35047a1af671ce7dce16a6863aaf81f4ba3e640" and "c2ef25c9cf40c9e72a1af0e4a53fb490b759f639" have entirely different histories.
b35047a1af
...
c2ef25c9cf
504
Cargo.lock
generated
504
Cargo.lock
generated
File diff suppressed because it is too large
Load diff
26
Cargo.toml
26
Cargo.toml
|
@ -10,17 +10,17 @@ description = "A command-line static site generator"
|
|||
homepage = "https://roxy-docs.netlify.app"
|
||||
|
||||
[dependencies]
|
||||
glob = "~0.3.1"
|
||||
syntect = "~5.2.0"
|
||||
roxy_markdown_parser = "~0.1.0"
|
||||
roxy_tera_parser = "~0.1.0"
|
||||
roxy_markdown_tera_rewriter = "~0.1.0"
|
||||
roxy_syntect = "~0.1.0"
|
||||
roxy_core = "~0.1.1"
|
||||
clap = { version = "~4.5.22", features = ["derive"] }
|
||||
toml = "~0.8.19"
|
||||
tera = "~1.20"
|
||||
serde = { version = "~1.0.215", features = ["derive"]}
|
||||
slugify = "~0.1.0"
|
||||
anyhow = "~1.0.94"
|
||||
glob = "0.3.1"
|
||||
syntect = "5.1.0"
|
||||
roxy_markdown_parser = "0.1.0"
|
||||
roxy_tera_parser = "0.1.0"
|
||||
roxy_markdown_tera_rewriter = "0.1.0"
|
||||
roxy_syntect = "0.1.0"
|
||||
roxy_core = "0.1.1"
|
||||
clap = { version = "4.4.17", features = ["derive"] }
|
||||
toml = "0.8.8"
|
||||
tera = "1.19.1"
|
||||
serde = { version = "1.0.195", features = ["derive"]}
|
||||
slugify = "0.1.0"
|
||||
anyhow = "1.0.79"
|
||||
|
||||
|
|
|
@ -48,7 +48,7 @@ impl Context {
|
|||
}
|
||||
}
|
||||
|
||||
pub fn from_files<'a, T: AsRef<Path> + std::fmt::Debug>(
|
||||
pub fn from_files<'a, T: AsRef<Path>>(
|
||||
files: Vec<&PathBuf>,
|
||||
file_path: &'a FilePath<T>,
|
||||
) -> Result<Context> {
|
||||
|
|
|
@ -16,7 +16,7 @@ impl<'a, P: AsRef<Path> + 'a> FilePath<'a, P> {
|
|||
pub fn new(input: &'a P, output: &'a P) -> Self {
|
||||
Self {
|
||||
input: Self::make_recursive(input),
|
||||
root_dir: Self::strip_wildcards(Self::strip_dot(&input)),
|
||||
root_dir: Self::strip_wildcards(input),
|
||||
output,
|
||||
slug_word_limit: Default::default(),
|
||||
}
|
||||
|
@ -30,10 +30,6 @@ impl<'a, P: AsRef<Path> + 'a> FilePath<'a, P> {
|
|||
!path.as_ref().contains("*")
|
||||
}
|
||||
|
||||
fn strip_dot(path: &P) -> &Path {
|
||||
path.as_ref().strip_prefix("./").unwrap_or(path.as_ref())
|
||||
}
|
||||
|
||||
fn strip_wildcards<P2: AsRef<Path> + ?Sized>(path: &'a P2) -> PathBuf {
|
||||
path.as_ref()
|
||||
.ancestors()
|
||||
|
@ -81,20 +77,3 @@ impl<'a, P: AsRef<Path> + 'a> FilePath<'a, P> {
|
|||
value.as_ref().strip_prefix(&self.root_dir)
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use std::path::Path;
|
||||
|
||||
use super::FilePath;
|
||||
|
||||
#[test]
|
||||
fn relative_paths() {
|
||||
let relative = FilePath::new(&"./in", &"./out");
|
||||
let bare = FilePath::new(&"in", &"out");
|
||||
let path = "in/nested/deeply/test.md" ;
|
||||
let expected = Path::new("nested/deeply/test.md");
|
||||
assert_eq!(expected, relative.strip_root(&path).unwrap());
|
||||
assert_eq!(expected, bare.strip_root(&path).unwrap());
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue