Compare commits
2 commits
c2ef25c9cf
...
b35047a1af
Author | SHA1 | Date | |
---|---|---|---|
|
b35047a1af | ||
|
bb088ef018 |
506
Cargo.lock
generated
506
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.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"
|
||||
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"
|
||||
|
||||
|
|
|
@ -48,7 +48,7 @@ impl Context {
|
|||
}
|
||||
}
|
||||
|
||||
pub fn from_files<'a, T: AsRef<Path>>(
|
||||
pub fn from_files<'a, T: AsRef<Path> + std::fmt::Debug>(
|
||||
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(input),
|
||||
root_dir: Self::strip_wildcards(Self::strip_dot(&input)),
|
||||
output,
|
||||
slug_word_limit: Default::default(),
|
||||
}
|
||||
|
@ -30,6 +30,10 @@ 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()
|
||||
|
@ -77,3 +81,20 @@ 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