From c469ce364ea9519893973f7f26b58597d66eba13 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tom=C3=A1=C5=A1=20Ml=C3=A1dek?= Date: Tue, 20 Oct 2020 19:13:51 +0200 Subject: [PATCH] limit default index to .md files only --- src/main.rs | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/main.rs b/src/main.rs index 8ac21e6..32f69e7 100644 --- a/src/main.rs +++ b/src/main.rs @@ -124,7 +124,14 @@ async fn render( if path.is_empty() { let location = match state.index_file.as_ref() { Some(index_file) => index_file.clone(), - None => files.get(0).unwrap().display().to_string(), + None => files + .iter() + .filter(|f| f.to_str().unwrap().ends_with(".md")) + .collect::>() + .first() + .unwrap_or(&files.first().unwrap()) + .display() + .to_string(), }; return Ok(HttpResponse::Found()