From 8a1b9baa4abe86e9f39461bdccea25b21224dbb3 Mon Sep 17 00:00:00 2001 From: Leon Ding Date: Tue, 16 Jul 2024 03:02:17 +0800 Subject: [PATCH] feat: add full text search document for html. --- README.md | 4 +- src/book/builder.rs | 12 +-- src/book/mod.rs | 4 +- src/book/{data.rs => search.rs} | 0 src/utils/file.rs | 2 +- theme/typikon-theme/index.html | 142 +++++++++++++++----------------- 6 files changed, 76 insertions(+), 88 deletions(-) rename src/book/{data.rs => search.rs} (100%) diff --git a/README.md b/README.md index 443a1a8..e873f7f 100644 --- a/README.md +++ b/README.md @@ -56,6 +56,4 @@ This project follows the all-contributors specification. All kinds of contributi > 中国大陆用户可以加微信群一起讨论设计与代码实现细节。 -Alt text - - +Alt text diff --git a/src/book/builder.rs b/src/book/builder.rs index eca7474..b469c7e 100644 --- a/src/book/builder.rs +++ b/src/book/builder.rs @@ -1,7 +1,7 @@ use tera::{Context, Tera}; use crate::{ - book::data::Document, + book::search::Document, cli, html::{self, Hypertext, Markdown, Template}, utils::{self, Logger}, @@ -146,10 +146,10 @@ impl Builder { // push full text search data self.document_index += 1; - let _ = &mut self.search_data.push(Document::new( + self.search_data.push(Document::new( self.document_index, "/index.html".to_string(), - template.name, + template.name.clone(), hypertext.to_html(), )); @@ -206,7 +206,7 @@ impl Builder { // push full text search data self.document_index += 1; - let _ = &mut self.search_data.push(Document::new( + self.search_data.push(Document::new( self.document_index, format!( "/{}/{}.html", @@ -267,7 +267,7 @@ impl Builder { // push full text search data self.document_index += 1; - let _ = &mut self.search_data.push(Document::new( + self.search_data.push(Document::new( self.document_index, format!( "/{}/index.html", @@ -324,7 +324,7 @@ impl Builder { chapter_path )); } - Err(_) => continue, + Err(_) => log.error(format_args!("file not found {:?}", &chapter_path)), } } diff --git a/src/book/mod.rs b/src/book/mod.rs index c52864f..7e6833b 100644 --- a/src/book/mod.rs +++ b/src/book/mod.rs @@ -1,9 +1,9 @@ pub mod builder; pub mod root; -pub mod data; +pub mod search; pub mod settings; pub use builder::*; pub use root::*; -pub use data::*; +pub use search::*; pub use settings::*; diff --git a/src/book/data.rs b/src/book/search.rs similarity index 100% rename from src/book/data.rs rename to src/book/search.rs diff --git a/src/utils/file.rs b/src/utils/file.rs index 663c118..56db5fc 100644 --- a/src/utils/file.rs +++ b/src/utils/file.rs @@ -42,7 +42,7 @@ pub fn remove_md_extension(filename: &str) -> String { } pub fn download_zip() -> Result<(), Box> { - let repo_url = "https://github.com/typikonbook/typikon-book/archive/refs/heads/main.zip"; + let repo_url = "https://github.com/typikonbook/typikon-book-v3/archive/refs/heads/main.zip"; let zip_path = Path::new("repo.zip"); let extract_path = Path::new("."); diff --git a/theme/typikon-theme/index.html b/theme/typikon-theme/index.html index d8eb1ab..4e7dfde 100644 --- a/theme/typikon-theme/index.html +++ b/theme/typikon-theme/index.html @@ -4,12 +4,11 @@ - {{ title }} - - - - + + + + {% for css_path in custom_css %} @@ -20,7 +19,6 @@ - @@ -41,7 +39,7 @@ -