Fix keyboard chapter navigation for `file` urls. (#915)

This commit is contained in:
Eric Huss 2019-05-07 15:29:46 -07:00 committed by Dylan DPC
parent a674c9eff1
commit 8bb5426441
2 changed files with 3 additions and 3 deletions

View File

@ -35,7 +35,7 @@ pub fn create_files(search_config: &Search, destination: &Path, book: &Book) ->
utils::fs::write_file( utils::fs::write_file(
destination, destination,
"searchindex.js", "searchindex.js",
format!("window.search = {};", index).as_bytes(), format!("Object.assign(window.search, {});", index).as_bytes(),
)?; )?;
utils::fs::write_file(destination, "searcher.js", searcher::JS)?; utils::fs::write_file(destination, "searcher.js", searcher::JS)?;
utils::fs::write_file(destination, "mark.min.js", searcher::MARK_JS)?; utils::fs::write_file(destination, "mark.min.js", searcher::MARK_JS)?;

View File

@ -427,8 +427,8 @@ mod search {
fn read_book_index(root: &Path) -> serde_json::Value { fn read_book_index(root: &Path) -> serde_json::Value {
let index = root.join("book/searchindex.js"); let index = root.join("book/searchindex.js");
let index = file_to_string(index).unwrap(); let index = file_to_string(index).unwrap();
let index = index.trim_start_matches("window.search = "); let index = index.trim_start_matches("Object.assign(window.search, ");
let index = index.trim_end_matches(';'); let index = index.trim_end_matches(");");
serde_json::from_str(&index).unwrap() serde_json::from_str(&index).unwrap()
} }