Skip to content

Commit d43af7a

Browse files
committed
feat: add slug as a handlebars variable
1 parent 99c6321 commit d43af7a

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

src/renderer/html_handlebars/hbs_renderer.rs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -298,6 +298,11 @@ impl HtmlHandlebars {
298298
ch.name.clone() + " - " + book_title
299299
};
300300

301+
let slug = Path::new(&ctx_path)
302+
.file_stem()
303+
.with_context(|| "Could not remove extension from path")?;
304+
305+
ctx.data.insert("slug".to_owned(), json!(slug.to_str()));
301306
ctx.data.insert("path".to_owned(), json!(path));
302307
ctx.data.insert("content".to_owned(), json!(content));
303308
ctx.data.insert("chapter_title".to_owned(), json!(ch.name));

0 commit comments

Comments
 (0)