Skip to content

Commit

Permalink
Make path relative
Browse files Browse the repository at this point in the history
  • Loading branch information
sakex committed Nov 7, 2023
1 parent a43dd2c commit 4978a9a
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions mdbook-tera-backend/src/tera_renderer/renderer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -62,8 +62,9 @@ impl Renderer {
/// `path`: The path to the file that will be added as extra context to the renderer.
fn create_context(&mut self, path: &Path) -> Result<tera::Context> {
let mut context = tera::Context::new();
context.insert("path", path);
context.insert("ctx", &serde_json::to_value(&self.ctx)?);
let book_dir = self.ctx.destination.parent().unwrap();
let relative_path = path.strip_prefix(&book_dir).unwrap();
context.insert("path", &path);
context.insert("book_dir", &self.ctx.destination.parent().unwrap());

Ok(context)
Expand Down

0 comments on commit 4978a9a

Please sign in to comment.