feat(title): add filename to title
This commit is contained in:
parent
ba2e11f07c
commit
4121f3481c
2
Cargo.lock
generated
2
Cargo.lock
generated
@ -687,7 +687,7 @@ checksum = "0e7465ac9959cc2b1404e8e2367b43684a6d13790fe23056cc8c6c5a6b7bcb94"
|
||||
|
||||
[[package]]
|
||||
name = "mdpreview"
|
||||
version = "0.1.0"
|
||||
version = "0.1.1"
|
||||
dependencies = [
|
||||
"axum",
|
||||
"clap",
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
[package]
|
||||
name = "mdpreview"
|
||||
version = "0.1.0"
|
||||
version = "0.1.1"
|
||||
edition = "2024"
|
||||
authors = ["Vladislav Kan <thek4n@yandex.ru>"]
|
||||
|
||||
|
||||
@ -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);
|
||||
|
||||
@ -3,7 +3,7 @@
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<title>Markdown Preview</title>
|
||||
<title>{{TITLE}}</title>
|
||||
<script src="https://cdn.jsdelivr.net/npm/mermaid@10/dist/mermaid.min.js"></script>
|
||||
<style>
|
||||
body { background-color: #121212; color: #e0e0e0; font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif; margin: 0; padding: 40px 20px; display: flex; justify-content: center; line-height: 1.6; }
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user