Skip to content

Commit 4978a9a

Browse files
committed
Make path relative
1 parent a43dd2c commit 4978a9a

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

mdbook-tera-backend/src/tera_renderer/renderer.rs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -62,8 +62,9 @@ impl Renderer {
6262
/// `path`: The path to the file that will be added as extra context to the renderer.
6363
fn create_context(&mut self, path: &Path) -> Result<tera::Context> {
6464
let mut context = tera::Context::new();
65-
context.insert("path", path);
66-
context.insert("ctx", &serde_json::to_value(&self.ctx)?);
65+
let book_dir = self.ctx.destination.parent().unwrap();
66+
let relative_path = path.strip_prefix(&book_dir).unwrap();
67+
context.insert("path", &path);
6768
context.insert("book_dir", &self.ctx.destination.parent().unwrap());
6869

6970
Ok(context)

0 commit comments

Comments
 (0)