diff options
author | Gaurav <allmanpride@gmail.com> | 2022-08-03 03:07:36 +0000 |
---|---|---|
committer | Gaurav <allmanpride@gmail.com> | 2022-08-14 00:03:55 +0000 |
commit | 03f798d71508cf0fe1856fce6e107229065c06cc (patch) | |
tree | 31574beb66346bfa2b7ec80da6146dc0a4e5764d /src/listing.rs | |
parent | Add `--readme` flag to cli (diff) | |
download | miniserve-03f798d71508cf0fe1856fce6e107229065c06cc.tar.gz miniserve-03f798d71508cf0fe1856fce6e107229065c06cc.zip |
Replace `markdown` by `comrak`; Render support for nested dirs
* README.md will be rendered at currently visiting directory instead
of just in the root.
* Rendering is now done by comrak, which seems heavy but has a lot
more features.
Diffstat (limited to 'src/listing.rs')
-rw-r--r-- | src/listing.rs | 8 |
1 files changed, 6 insertions, 2 deletions
diff --git a/src/listing.rs b/src/listing.rs index 458744c..436add9 100644 --- a/src/listing.rs +++ b/src/listing.rs @@ -232,7 +232,7 @@ pub fn directory_listing( } let mut entries: Vec<Entry> = Vec::new(); - let mut readme: Option<String> = None; + let mut readme: Option<PathBuf> = None; for entry in dir.path.read_dir()? { if dir.is_visible(&entry) || conf.show_hidden { @@ -285,7 +285,11 @@ pub fn directory_listing( )); // TODO: Pattern match? if conf.readme && file_name.to_lowercase() == "readme.md"{ - readme = Some(file_name); + let file_path = conf.path.canonicalize().unwrap() + .join(base.as_os_str().to_str().unwrap() + .strip_prefix("/").unwrap()) + .join(&file_name); + readme = Some(file_path); } } } else { |