From 97cb77bbdd700c6e06011a1150bc8f499a1f7ade Mon Sep 17 00:00:00 2001 From: rsapkf Date: Sat, 20 Nov 2021 02:11:47 -0500 Subject: [PATCH 1/2] Add proper title to 404 page --- src/renderer/html_handlebars/hbs_renderer.rs | 1 + 1 file changed, 1 insertion(+) diff --git a/src/renderer/html_handlebars/hbs_renderer.rs b/src/renderer/html_handlebars/hbs_renderer.rs index a73e5082..0374fc07 100644 --- a/src/renderer/html_handlebars/hbs_renderer.rs +++ b/src/renderer/html_handlebars/hbs_renderer.rs @@ -170,6 +170,7 @@ impl HtmlHandlebars { // Set a dummy path to ensure other paths (e.g. in the TOC) are generated correctly data_404.insert("path".to_owned(), json!("404.md")); data_404.insert("content".to_owned(), json!(html_content_404)); + data_404.insert("title".to_owned(), json!("Page not found")); let rendered = handlebars.render("index", &data_404)?; let rendered = From 675c8c3f4e391b7ea56c41cb60ec071108df73aa Mon Sep 17 00:00:00 2001 From: Eric Huss Date: Sun, 27 Mar 2022 17:17:20 -0700 Subject: [PATCH 2/2] Add book title to 404 page title. --- src/renderer/html_handlebars/hbs_renderer.rs | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/renderer/html_handlebars/hbs_renderer.rs b/src/renderer/html_handlebars/hbs_renderer.rs index 0374fc07..946ce482 100644 --- a/src/renderer/html_handlebars/hbs_renderer.rs +++ b/src/renderer/html_handlebars/hbs_renderer.rs @@ -170,7 +170,13 @@ impl HtmlHandlebars { // Set a dummy path to ensure other paths (e.g. in the TOC) are generated correctly data_404.insert("path".to_owned(), json!("404.md")); data_404.insert("content".to_owned(), json!(html_content_404)); - data_404.insert("title".to_owned(), json!("Page not found")); + + let mut title = String::from("Page not found"); + if let Some(book_title) = &ctx.config.book.title { + title.push_str(" - "); + title.push_str(book_title); + } + data_404.insert("title".to_owned(), json!(title)); let rendered = handlebars.render("index", &data_404)?; let rendered =