limit default index to .md files only

This commit is contained in:
Tomáš Mládek 2020-10-20 19:13:51 +02:00
parent bf423261ac
commit c469ce364e

View file

@ -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::<Vec<&PathBuf>>()
.first()
.unwrap_or(&files.first().unwrap())
.display()
.to_string(),
};
return Ok(HttpResponse::Found()