Skip to content

Commit

Permalink
feat: add slug as a handlebars variable
Browse files Browse the repository at this point in the history
  • Loading branch information
Phosphorus-M committed Mar 15, 2024
1 parent 99c6321 commit d43af7a
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions src/renderer/html_handlebars/hbs_renderer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -298,6 +298,11 @@ impl HtmlHandlebars {
ch.name.clone() + " - " + book_title
};

let slug = Path::new(&ctx_path)
.file_stem()
.with_context(|| "Could not remove extension from path")?;

ctx.data.insert("slug".to_owned(), json!(slug.to_str()));
ctx.data.insert("path".to_owned(), json!(path));
ctx.data.insert("content".to_owned(), json!(content));
ctx.data.insert("chapter_title".to_owned(), json!(ch.name));
Expand Down

0 comments on commit d43af7a

Please sign in to comment.