diff --git a/book-example/book/README.html b/book-example/book/README.html index 1d370558..c9ff38be 100644 --- a/book-example/book/README.html +++ b/book-example/book/README.html @@ -46,9 +46,11 @@ Issues and feature requests can be posted on the + diff --git a/book-example/book/book.js b/book-example/book/book.js index d3cff82f..643755e5 100644 --- a/book-example/book/book.js +++ b/book-example/book/book.js @@ -14,13 +14,4 @@ $( document ).ready(function() { } }); - - // Hide navigation icons when there is no next or previous link - // JavaScript Solution until I find a way to do this in the template - $(".nav-chapters").each(function(){ - if(!$(this).attr('href')){ - this.remove(); - } - }); - }); diff --git a/book-example/book/cli/build.html b/book-example/book/cli/build.html index 35cd3293..93b623c4 100644 --- a/book-example/book/cli/build.html +++ b/book-example/book/cli/build.html @@ -50,16 +50,18 @@ current working directory.
alternative until I find a way to do it in the template --> - - null + + + + diff --git a/book-example/book/cli/cli-tool.html b/book-example/book/cli/cli-tool.html index ffb7adae..353fe924 100644 --- a/book-example/book/cli/cli-tool.html +++ b/book-example/book/cli/cli-tool.html @@ -38,16 +38,18 @@ Let's focus on the command line tool capabilities first. alternative until I find a way to do it in the template --> - - null + + + + diff --git a/book-example/book/cli/init.html b/book-example/book/cli/init.html index e6e7c6e4..2044d848 100644 --- a/book-example/book/cli/init.html +++ b/book-example/book/cli/init.html @@ -67,16 +67,18 @@ not create the corresponding files, init command should create the files for him alternative until I find a way to do it in the template --> - - null + + + + diff --git a/book-example/book/format/config.html b/book-example/book/format/config.html index 95c4cdf2..f37a6042 100644 --- a/book-example/book/format/config.html +++ b/book-example/book/format/config.html @@ -49,16 +49,14 @@ alternative until I find a way to do it in the template --> - - null + + - - - + diff --git a/book-example/book/index.html b/book-example/book/index.html index 1d370558..c9ff38be 100644 --- a/book-example/book/index.html +++ b/book-example/book/index.html @@ -46,9 +46,11 @@ Issues and feature requests can be posted on the + diff --git a/src/renderer/html_handlebars/hbs_navigation_helper.rs b/src/renderer/html_handlebars/hbs_navigation_helper.rs index 817d37e5..cb8209e4 100644 --- a/src/renderer/html_handlebars/hbs_navigation_helper.rs +++ b/src/renderer/html_handlebars/hbs_navigation_helper.rs @@ -56,7 +56,7 @@ pub fn previous(c: &Context, _h: &Helper, r: &Handlebars, rc: &mut RenderContext Path::new(previous.get("path").unwrap()) .with_extension("html") ).to_str().unwrap()); - + previous_chapter.insert( "link".to_string(), path_to_root.join( @@ -67,11 +67,11 @@ pub fn previous(c: &Context, _h: &Helper, r: &Handlebars, rc: &mut RenderContext debug!("[*]: Inject in context"); // Inject in current context - c.extend(&previous_chapter); + let updated_context = c.extend(&previous_chapter); debug!("[*]: Render template"); // Render template - _h.template().unwrap().render(c, r, rc).unwrap(); + _h.template().unwrap().render(&updated_context, r, rc).unwrap(); } break; @@ -88,36 +88,81 @@ pub fn previous(c: &Context, _h: &Helper, r: &Handlebars, rc: &mut RenderContext -pub fn next(c: &Context, _h: &Helper, _: &Handlebars, rc: &mut RenderContext) -> Result<(), RenderError> { +pub fn next(c: &Context, _h: &Helper, r: &Handlebars, rc: &mut RenderContext) -> Result<(), RenderError> { + debug!("[fn]: next (handlebars helper)"); + + debug!("[*]: Get data from context"); // get value from context data // rc.get_path() is current json parent path, you should always use it like this // param is the key of value you want to display let chapters = c.navigate(rc.get_path(), "chapters"); - let current = c.navigate(rc.get_path(), "path").to_string().replace("\"", ""); - let path_to_root = c.navigate(rc.get_path(), "path_to_root").to_string().replace("\"", ""); + let current = c.navigate(rc.get_path(), "path") + .to_string() + .replace("\"", ""); + + let path_to_root = PathBuf::from( + c.navigate(rc.get_path(), "path_to_root") + .to_string() + .replace("\"", "") + ); + + debug!("[*]: Decode chapters from JSON"); // Decode json format - let decoded: Vec