From e4d8f9c8e83068d72be87881adf4e2a81536ad5a Mon Sep 17 00:00:00 2001 From: Gregory Marco Date: Sun, 4 May 2025 00:37:12 -0500 Subject: [PATCH] If its not a markdown file just return the file name itself, because then it's probably a directory. --- src/lib.rs | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/lib.rs b/src/lib.rs index 426f42b..9855eaf 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -321,7 +321,12 @@ fn render_markdown (content: &tera::Value, args: &HashMap) } fn file_stem (content: &tera::Value, args: &HashMap) -> tera::Result { - Ok(tera::Value::String(Path::new(content.as_str().expect("as_str")).file_stem().expect("file_stem").to_str().expect("to_str").to_owned())) + let content_as_str = content.as_str().expect("as_str"); + if !content_as_str.ends_with(MD_EXTENSION) { + Ok(content.clone()) + } else { + Ok(tera::Value::String(Path::new(content_as_str).file_stem().expect("file_stem").to_str().expect("to_str").to_owned())) + } } impl PageRenderer {