Fix #40 where next helper returned a link to the current chapter instead of the next

This commit is contained in:
Mathieu David 2015-08-12 19:22:53 +02:00
parent 0932bfd576
commit 10d756eff0

View file

@ -149,12 +149,12 @@ pub fn next(c: &Context, _h: &Helper, r: &Handlebars, rc: &mut RenderContext) ->
if let Some(previous) = previous { if let Some(previous) = previous {
let path = match previous.get("path") { let previous_path = match previous.get("path") {
Some(p) => p, Some(p) => p,
None => return Err(RenderError{ desc: "No path found for chapter in JSON data"}) None => return Err(RenderError{ desc: "No path found for chapter in JSON data"})
}; };
if path == &current { if previous_path == &current {
debug!("[*]: Found current chapter"); debug!("[*]: Found current chapter");
debug!("[*]: Creating BTreeMap to inject in context"); debug!("[*]: Creating BTreeMap to inject in context");
@ -169,6 +169,7 @@ pub fn next(c: &Context, _h: &Helper, r: &Handlebars, rc: &mut RenderContext) ->
None => return Err(RenderError{ desc: "No title found for chapter in JSON data"}) None => return Err(RenderError{ desc: "No title found for chapter in JSON data"})
} }
let link = path_to_root.join(Path::new(path).with_extension("html")); let link = path_to_root.join(Path::new(path).with_extension("html"));
debug!("[*]: Inserting link: {:?}", link); debug!("[*]: Inserting link: {:?}", link);