|
1 | 1 | use crate::book::{Book, BookItem};
|
2 |
| -use crate::config::{Config, HtmlConfig, Playground, RustEdition}; |
| 2 | +use crate::config::{BookConfig, Config, HtmlConfig, Playground, RustEdition}; |
3 | 3 | use crate::errors::*;
|
4 | 4 | use crate::renderer::html_handlebars::helpers;
|
5 | 5 | use crate::renderer::{RenderContext, Renderer};
|
@@ -38,12 +38,14 @@ impl HtmlHandlebars {
|
38 | 38 | };
|
39 | 39 |
|
40 | 40 | if let Some(ref edit_url_template) = ctx.html_config.edit_url_template {
|
41 |
| - let full_path = "src/".to_owned() |
| 41 | + let full_path = ctx.book_config.src.to_str().unwrap_or_default().to_owned() |
| 42 | + + "/" |
42 | 43 | + ch.source_path
|
43 | 44 | .clone()
|
44 | 45 | .unwrap_or_default()
|
45 | 46 | .to_str()
|
46 | 47 | .unwrap_or_default();
|
| 48 | + |
47 | 49 | let edit_url = edit_url_template.replace("{path}", &full_path);
|
48 | 50 | ctx.data
|
49 | 51 | .insert("git_repository_edit_url".to_owned(), json!(edit_url));
|
@@ -458,6 +460,7 @@ impl Renderer for HtmlHandlebars {
|
458 | 460 | }
|
459 | 461 |
|
460 | 462 | fn render(&self, ctx: &RenderContext) -> Result<()> {
|
| 463 | + let book_config = &ctx.config.book; |
461 | 464 | let html_config = ctx.config.html_config().unwrap_or_default();
|
462 | 465 | let src_dir = ctx.root.join(&ctx.config.book.src);
|
463 | 466 | let destination = &ctx.destination;
|
@@ -520,6 +523,7 @@ impl Renderer for HtmlHandlebars {
|
520 | 523 | destination: destination.to_path_buf(),
|
521 | 524 | data: data.clone(),
|
522 | 525 | is_index,
|
| 526 | + book_config: book_config.clone(), |
523 | 527 | html_config: html_config.clone(),
|
524 | 528 | edition: ctx.config.rust.edition,
|
525 | 529 | chapter_titles: &ctx.chapter_titles,
|
@@ -936,6 +940,7 @@ struct RenderItemContext<'a> {
|
936 | 940 | destination: PathBuf,
|
937 | 941 | data: serde_json::Map<String, serde_json::Value>,
|
938 | 942 | is_index: bool,
|
| 943 | + book_config: BookConfig, |
939 | 944 | html_config: HtmlConfig,
|
940 | 945 | edition: Option<RustEdition>,
|
941 | 946 | chapter_titles: &'a HashMap<PathBuf, String>,
|
|
0 commit comments