From 4121f3481c930b6cf22461a04055c27c0ea892a5 Mon Sep 17 00:00:00 2001 From: thek4n Date: Fri, 20 Mar 2026 21:57:54 +0300 Subject: [PATCH] feat(title): add filename to title --- Cargo.lock | 2 +- Cargo.toml | 2 +- src/main.rs | 7 +++++++ templates/file.html | 2 +- 4 files changed, 10 insertions(+), 3 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 0b2eeef..b22d3df 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -687,7 +687,7 @@ checksum = "0e7465ac9959cc2b1404e8e2367b43684a6d13790fe23056cc8c6c5a6b7bcb94" [[package]] name = "mdpreview" -version = "0.1.0" +version = "0.1.1" dependencies = [ "axum", "clap", diff --git a/Cargo.toml b/Cargo.toml index 12d1d93..d1a6a52 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "mdpreview" -version = "0.1.0" +version = "0.1.1" edition = "2024" authors = ["Vladislav Kan "] diff --git a/src/main.rs b/src/main.rs index 34fc9ef..cc33f08 100644 --- a/src/main.rs +++ b/src/main.rs @@ -248,8 +248,15 @@ async fn serve_file( let html_content = markdown_to_html(&content, &state.syntax_set, &state.theme_set, &full_path); + let filename: String = if let Some(filename) = PathBuf::from(&full_path).file_name() { + filename.to_str().unwrap_or("Markdown Preview").to_string() + } else { + "Markdown Preview".to_string() + }; + // Заполнение шаблона let final_html = TEMPLATE_FILE + .replace("{{TITLE}}", &filename) .replace("{{CONTENT}}", &html_content) .replace("{{SSE_URL}}", &format!("/events/{full_path}")) .replace("{{BACK_LINK}}", &back_link); diff --git a/templates/file.html b/templates/file.html index 87ec8e5..3ec4a26 100644 --- a/templates/file.html +++ b/templates/file.html @@ -3,7 +3,7 @@ - Markdown Preview + {{TITLE}}