remove treehouse-format crate and collapse everything into src
This commit is contained in:
parent
ca127a9411
commit
b792688776
66 changed files with 145 additions and 112 deletions
36
src/vfs/html_canonicalize.rs
Normal file
36
src/vfs/html_canonicalize.rs
Normal file
|
@ -0,0 +1,36 @@
|
|||
use core::fmt;
|
||||
|
||||
use super::{Dir, Query, VPath};
|
||||
|
||||
pub struct HtmlCanonicalize<T> {
|
||||
inner: T,
|
||||
}
|
||||
|
||||
impl<T> HtmlCanonicalize<T> {
|
||||
pub fn new(inner: T) -> Self {
|
||||
Self { inner }
|
||||
}
|
||||
}
|
||||
|
||||
impl<T> Dir for HtmlCanonicalize<T>
|
||||
where
|
||||
T: Dir,
|
||||
{
|
||||
fn query(&self, path: &VPath, query: &mut Query) {
|
||||
let mut path = path.to_owned();
|
||||
if path.extension() == Some("html") {
|
||||
path.set_extension("");
|
||||
}
|
||||
|
||||
self.inner.query(&path, query);
|
||||
}
|
||||
}
|
||||
|
||||
impl<T> fmt::Debug for HtmlCanonicalize<T>
|
||||
where
|
||||
T: fmt::Debug,
|
||||
{
|
||||
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
|
||||
write!(f, "HtmlCanonicalize({:?})", self.inner)
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue