Skip to content

Commit d42c4bb

Browse files
committed
chore: use mdbook 0.4.45
1 parent b550d22 commit d42c4bb

File tree

2 files changed

+19
-3
lines changed

2 files changed

+19
-3
lines changed

Cargo.toml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,12 +13,12 @@ drop_this = { version = "0.0", features = ["tokio"] }
1313
futures-util = "0.3"
1414
handlebars = "6"
1515
ignore = "0.4"
16-
mdbook = { package = "mdbook_fork4ls", version = "0.4.41", features = [
16+
mdbook = { package = "mdbook_fork4ls", version = "0.4.45", features = [
1717
"search",
1818
], default-features = false }
1919
mdbook_incremental_preview = { path = "mdbook_incremental_preview", version = "0.0" }
20-
notify = "6"
21-
notify-debouncer-mini = "0.4"
20+
notify = "8"
21+
notify-debouncer-mini = "0.6"
2222
once_cell = "1"
2323
opener = "0.7"
2424
pathdiff = "0.2"

mdbook_incremental_preview/src/rendering.rs

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,10 @@ pub fn html_config_n_theme_dir_n_theme_n_handlebars(
7878
debug!("Register the header handlebars template");
7979
handlebars.register_partial("header", String::from_utf8(theme.header.clone())?)?;
8080

81+
debug!("Register the toc handlebars template");
82+
handlebars.register_template_string("toc_js", String::from_utf8(theme.toc_js.clone())?)?;
83+
handlebars.register_template_string("toc_html", String::from_utf8(theme.toc_html.clone())?)?;
84+
8185
debug!("Register handlebars helpers");
8286
RENDERER.register_hbs_helpers(&mut handlebars, &html_config);
8387

@@ -200,6 +204,18 @@ impl HtmlHbsState {
200204
debug!("Created print.html ✓");
201205
}
202206

207+
debug!("Render toc");
208+
{
209+
let rendered_toc = handlebars.render("toc_js", &data)?;
210+
utils::fs::write_file(destination, "toc.js", rendered_toc.as_bytes())?;
211+
debug!("Creating toc.js ✓");
212+
data.insert("is_toc_html".to_owned(), json!(true));
213+
let rendered_toc = handlebars.render("toc_html", &data)?;
214+
utils::fs::write_file(destination, "toc.html", rendered_toc.as_bytes())?;
215+
debug!("Creating toc.html ✓");
216+
data.remove("is_toc_html");
217+
}
218+
203219
// Render search index
204220
let search = html_config.search.clone().unwrap_or_default();
205221
if search.enable {

0 commit comments

Comments
 (0)